About Thinkphp's cache

The default cache configuration of TP is'type' =>'file', how to change it to redis?


//首先看手册https://www.kancloud.cn/manual/thinkphp5/118131
//1.修改config.php的配置文件
 
'cache'                  => [
    // 驱动方式
    'type'   => 'redis',
    'host'   => '127.0.0.1',
    'port'   => '6379',
    'password' => '',
    // 缓存前缀
    'prefix' => '',
    // 缓存有效期 0表示永久缓存
    'expire' => 0,

2.控制器中 
use think\Cache;
3.我做的是清楚缓存的操作,可以看手册做其他的操作使用。
Cache::clear();

 

Guess you like

Origin blog.csdn.net/EasyTure/article/details/112847107