Laravel 5 - Cache remember doesn't work

10,520
  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.
Share:
10,520
Heril Muratovic
Author by

Heril Muratovic

Working Experience: 2014-2016 Software developer at Information Technology Systems Technology stack: PHP HTML5, CSS3 JavaScript / jQuery MySQL Linux 2016-present Software developer at Logate d.o.o Technology stack: Spring Boot Framework Android (Native and Hybrid) development MySQL Web Services AngularJS Linux Server Administration LinkedIn profile: https://me.linkedin.com/in/heril-muratovic-021097132

Updated on June 04, 2022

Comments

  • Heril Muratovic
    Heril Muratovic almost 2 years

    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?