laravel Redis缓存

laravel Redis缓存_第1张图片

首先在app/config/cache.php配置文件下改变一下缓存的驱动方式改为redis

composer require predis/predis

 

先安装conposer的扩展安装包

laravel Redis缓存_第2张图片

然后在composer.josn的文件中加入这一句

然后执行

composer update

 

导入

use Illuminate\Support\Facades\Cache;

 

获取缓存的参数

$value = Cache::get('key');

 

写入缓存     1.键   2.值  3多长时间过期,按照分钟来算的一天的话1450分钟

Cache::put('key', 'value', $minutes);

 

判断是否存在

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

 

 

这只是基础的,更多的看文档吧

https://d.laravel-china.org/docs/5.4/cache#driver-prerequisites

 

转载于:https://www.cnblogs.com/wlphp/p/8447121.html

你可能感兴趣的:(laravel Redis缓存)