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
Laravel 5 - Cache remember doesn't work
提问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);
Storage
permissions => 777
Cache path
=> storage_path('framework/cache')
Storage
权限 => 777
Cache path
=>storage_path('framework/cache')
Does anyone have an idea?
有没有人有想法?
采纳答案by Heril Muratovic
php artisan cache:clear
- if you have run
php artisan config:cache
before then you have to deleteconfig.php
file frombootstrap/cache/
, if not then just run first command (1.) - Try to run your code for caching data.
php artisan cache:clear
- 如果您之前运行
php artisan config:cache
过,则必须从中删除config.php
文件bootstrap/cache/
,否则只需运行第一个命令(1.) - 尝试运行您的代码来缓存数据。