Laravel 之Cache缓存

mac2022-06-30  22

写入缓存

Cache::put('key','value',10);//设置10分钟

 

获取缓存

Cache::get('key');

 

增加缓存

Cache::add('key','value',10);//返回布尔值,如果已存在返回false,否则返回true。

 

设置永久缓存

Cache::forever('key','value');

 

判断缓存是否存在

if(Cache::has('key')){

  //存在

}else{

  //不存在

}

 

获取并删除缓存

Cache::pull('key');//获取之后会自动删除

 

删除缓存

Cache::forget('key');

转载于:https://www.cnblogs.com/gyfluck/p/9083477.html

最新回复(0)