Laravel 5 cacheTags 路径
Laravel 5 cacheTags path
cacheTags 需要什么 use 子句?
我有:
$categories = FinanceTransactionCategory::select('id')
->cacheTags(['cell-editors', 'categories'])
->remember(60)->get();
$jsConfig['filters'] = [
'category' => $categories
];
但它不起作用,因为:
Call to undefined method Illuminate\Database\Query\Builder::cacheTags()
这已在 Laravel 5 中删除。看这里:
https://github.com/laravel/framework/issues/7259
您现在会想直接使用缓存。这应该有帮助:
http://laravel.com/docs/5.0/cache#cache-tags
这里有一个讨论也可能有用:
所以我相信这段(未经测试的)代码可以满足您的要求:
$categories = Cache::tags(['cell-editors', 'categories'])->remember('categories', 60, function() {
return FinanceTransactionCategory::select('id')->get();
});
或者至少让你朝着正确的方向前进!
cacheTags 需要什么 use 子句?
我有:
$categories = FinanceTransactionCategory::select('id')
->cacheTags(['cell-editors', 'categories'])
->remember(60)->get();
$jsConfig['filters'] = [
'category' => $categories
];
但它不起作用,因为:
Call to undefined method Illuminate\Database\Query\Builder::cacheTags()
这已在 Laravel 5 中删除。看这里:
https://github.com/laravel/framework/issues/7259
您现在会想直接使用缓存。这应该有帮助:
http://laravel.com/docs/5.0/cache#cache-tags
这里有一个讨论也可能有用:
所以我相信这段(未经测试的)代码可以满足您的要求:
$categories = Cache::tags(['cell-editors', 'categories'])->remember('categories', 60, function() {
return FinanceTransactionCategory::select('id')->get();
});
或者至少让你朝着正确的方向前进!