首页 > 编程知识 正文

redis缓存操作的原子性,c盘缓存文件

时间:2023-05-06 21:07:05 阅读:207339 作者:3430

1、缓存配置文件 /config/cache.php 可以查看所有的缓存配置信息

2、默认file缓存文件存放在 /storage/framework/cache/data/

3、需要引入Cache对象  

use IlluminateSupportFacadesCache;

4、常用Cache缓存操作方法

//写入缓存方法集合 public function setCache(){ //put(键名,键值,缓存有效期分钟) 没有返回值 Cache::put('key2','value2',10); //add() 有一个bool的返回值 key1存在返回false,不存在返回true $bool = Cache::add('key1','value1',10); //forerve() 永久有效缓存 Cache::forever('key3','value3'); //has() 有一个bool的返回值 key1存在返回false,不存在返回true $bool = Cache::has('key1'); } //取出缓存方法集合 public function getCache(){ //get(键名) 存在返回简直,不存在返回NULL $v1 = Cache::get('key3'); var_dump($v1); //pull(键名) 取出缓存并删除 Cache::pull('key3'); //forget() 从缓存中删除对象,有一个bool返回值,成功返回true,失败返回false $bool = Cache::forget('key2'); }

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。