Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 - Cache remember doesn't work

I have tried to cache some queries with Cache::remember(); but it doesn't work.

My script response code is 500(Internal Server Error).

Here is my code:

 $filters = \Cache::remember("cache_filter", 20, function(){
      $data['value1'] = MyClass::where('<condition>')->get();
      $data['value2'] = MyClass::where('<condition>')->get();
      $data['value3'] = MyClass::where('<condition>')->get();

      return $data;
 });     
 return view('custom.show')->with($filters);

Storage permissions => 777
Cache path => storage_path('framework/cache')

Does anyone have an idea?

like image 396
Heril Muratovic Avatar asked Mar 06 '26 20:03

Heril Muratovic


1 Answers

  1. php artisan cache:clear
  2. if you have run php artisan config:cache before then you have to delete config.php file from bootstrap/cache/, if not then just run first command (1.)
  3. Try to run your code for caching data.
like image 57
Heril Muratovic Avatar answered Mar 09 '26 08:03

Heril Muratovic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!