首页 > 解决方案 > 如何在 laravel 缓存中每次更新后重置缓存

问题描述

我有一个模型,我在它上面使用了缓存,如下所示:

   public function fulfilledWish()
    {
        return Cache::remember('fulfilled_wish', 5, function () {
            return Model::with(['media', 'slug'])
                ->where('type_id', 2)
                ->take(4)
                ->get();
        });

我希望在模型上每次更新或创建后更新缓存,就像scout在 laravel 中一样。有什么解决办法吗?

标签: phpmysqllaravelcachingredis

解决方案


推荐阅读