TP5使用redis

安装redis后,先引入

 use think\cache\driver\Redis;
控制器中写
//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'); //你好啊
posted @ 2019-12-17 10:47  大熊童鞋  阅读(1345)  评论(0编辑  收藏  举报