[英]is remember keyword enough for caching paginated query results
我有以下查询:
$posts = Post::where('category_id', '=', $category->id)
->where('isOk', '=', True)
->orderBy('submitTimestamp', 'desc')
->paginate(20);
如果我在查询中插入->remember(10)
,是否可以成功执行请求页面的缓存?
其次,当(例如)插入新帖子时,如何忘记所有(某个类别的)缓存页面?
如果您需要刷新所有某种类型的文件(例如所有帖子),那么您想查找缓存标签而不是使用雄辩的缓存。 这将给您更多的控制权,并允许您刷新缓存集的组。
从Laravel文档中:
// Setting tagged cached item in 'people' > 'authors'
Cache::tags('people', 'authors')->put('John', $john, $minutes);
// Retrieving a cached item from a tag of 'people' > 'artists'
$anne = Cache::tags('people', 'authors')->get('John');
// Removing all items with a tag of 'people'
Cache::tags('people')->flush();
有关缓存标签的更多信息: http : //laravel.com/docs/cache#cache-tags
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.