thinkphp3.2.3 连接redis步骤

@fright  December 6, 2017

1、依赖PHP-redis 扩展
http://windows.php.net/downloads/pecl/releases/redis/
找到适合vc库版本的包(32位)

2、ThinkCacheDriverRedis
在构造函数中加入

$this->handler->auth($options['auth']);  //加入令牌
$this->handler->select($options['database']);

3、调用方式

$cache = Cache::getInstance('redis',
[
    'host' => '',
    'port' => '6379',
    'database' => '选择的库',
    'auth' => '密码'
]
);
$info = $cache->get(key);
$cache->set(key,value);

评论已关闭