Laravel的缓存使用方法

1、cache()
可以直接存取数组,不用序列化,推荐使用
设置方法:cache([key => value], expire);
key: 缓存的键
value: 缓存的值
expire: 缓存的有效时间,单位是分钟
取缓存:cache(key);

2、Redis
设置方法:Redis::setex(key, expire, value);
key: 缓存的键
value: 缓存的值,如果是数组必须序列化后再存取,取出则需反序列化后使用
expire: 缓存的有效时间,单位是秒
取缓存:Redis::get(key);

猜你喜欢

转载自blog.csdn.net/lzhou926/article/details/79971740
今日推荐