Laravel 5 - 缓存记忆不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35937153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:23:45  来源:igfitidea点击:

Laravel 5 - Cache remember doesn't work

phplaravelcachinglaravel-5internal-server-error

提问by Heril Muratovic

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

我试图用 Cache::remember(); 缓存一些查询;但它不起作用。

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

我的脚本响应代码是 500(内部服务器错误)。

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);

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

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

Does anyone have an idea?

有没有人有想法?

采纳答案by Heril Muratovic

  1. php artisan cache:clear
  2. if you have run php artisan config:cachebefore then you have to delete config.phpfile from bootstrap/cache/, if not then just run first command (1.)
  3. Try to run your code for caching data.
  1. php artisan cache:clear
  2. 如果您之前运行php artisan config:cache过,则必须从中删除config.php文件bootstrap/cache/,否则只需运行第一个命令(1.)
  3. 尝试运行您的代码来缓存数据。