Laravel 5-缓存记住不起作用 [英] Laravel 5 - Cache remember doesn't work

查看:214
本文介绍了Laravel 5-缓存记住不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Cache :: remember();来缓存一些查询.但这是行不通的.

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

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

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

这是我的代码:

 $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权限=> 777
Cache path => storage_path('framework/cache')

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

有人有主意吗?

推荐答案

  1. php artisan cache:clear
  2. 如果您之前已经运行过php artisan config:cache,则必须从bootstrap/cache/中删除config.php文件,如果没有,则只需运行第一个命令(1.)
  3. 尝试运行代码以缓存数据.
  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.

这篇关于Laravel 5-缓存记住不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆