我尝试用Cache::remember()缓存一些查询;但它不起作用。
我的脚本响应代码是 500(内部服务器错误)。
这是我的代码:
$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')
有人有想法吗?
-
php artisan cache:clear
- 如果您之前运行过
php artisan config:cache
那么您必须从bootstrap/cache/
中删除config.php
文件,如果没有,则只需运行第一个命令(1)。 - 尝试运行代码以缓存数据。