php - 如何在 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 中一样。有什么解决办法吗?
解决方案
推荐阅读
- ignite - 点燃私有 IP 用于同步和公共 ip 用于读取
- google-cloud-platform - 主键和索引
- python-3.x - 从对话框的 GTK 条目中获取文本
- php - 如何从服务器上的 php 文件中获取 json 数据到 Flutter 应用程序
- python - 不能按月对 Pandas 列中的值进行分组
- javascript - 无法获取用于 Twitter 共享的图像
- python - 如何从python3中的子列表访问零索引和日期索引之间的元素?
- php - 为什么我的 php 脚本不向 mysql 插入数据
- alias - 如何在 Angular 8 中使用别名?
- spring-boot - Spring Boot 拦截服务方法