v4.7版本增加缓存使用统一调用方式,增加了每一个模型之前的缓存前缀进行隔离缓存。不用担心设置的缓存key是否和其他地方冲突。
缓存保存方式
默认使用系统配置缓存保存方式来存放缓存,建议使用redis类型
使用方式
在services中可以直接使用
$this->cacheDriver()
可以使用内置方法
//获取缓存数据
$this->cacheDriver()->get(value1,value2)
//缓存在直接读取,不在则使用闭包内返回的数据
$this->cacheDriver()->remember(value1,value2,value3)
//删除缓存
$this->cacheDriver()->delete(value1)
//当前数据表缓存是否存在
$this->cacheDriver()->has(value1)
//设置缓存加入当前数据表
$this->cacheDriver()->set(value1,value2)
//清除当前数据表下的所有数据缓存
$this->cacheDriver()->clear()
Was this helpful?
0 / 0