TP5使用redis

安装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'); //你好啊
世界上最美的风景,是自己努力的模样
原文地址:https://www.cnblogs.com/xiong-hua/p/12053183.html