安装redis后,先引入
use thinkcachedriverRedis;
控制器中写
//redis参数 $options= [ 'host' => '127.0.0.1', 'port' => 6379, 'password' => 'xxxxx', 'select' => 0, 'timeout' => 0, 'expire' => 0, 'persistent' => false, 'prefix' => '', ];
$redis= new Redis($options);
$redis->set('name','你好啊');
$res = $redis->get('name'); //你好啊