1、缓存配置文件 /config/cache.php 可以查看所有的缓存配置信息
2、默认file缓存文件存放在 /storage/framework/cache/data/
3、需要引入Cache对象
use Illuminate\Support\Facades\Cache;
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');
}