首先之前记得装好redis扩展
头文件
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\view;
use think\Cache;
use think\cache\driver\Redis;
//使用复合型缓存类型
'cache' => [
// 使用复合缓存类型
'type' => 'complex',
// 默认使用的缓存
'default' => [
// 驱动方式
'type' => 'redis',
// 缓存保存目录
'path' => CACHE_PATH,
],
// 文件缓存
'file' => [
// 驱动方式
'type' => 'file',
// 设置不同的缓存保存目录
'path' => RUNTIME_PATH . 'file/',
],
// redis缓存
'redis' => [<