优化 redis connect time, redis扩展已兼容time参数

This commit is contained in:
尘缘
2016-05-08 08:48:49 +08:00
parent 0982878a0c
commit 0061f52a31

View File

@@ -15,7 +15,9 @@ use think\Cache;
use think\Exception;
/**
* Redis缓存驱动
* Redis缓存驱动,适合单机部署、有前端代理实现高可用的场景,性能最好
* 有需要在业务层实现读写分离、或者使用RedisCluster的需求请使用Redisd驱动
*
* 要求安装phpredis扩展https://github.com/nicolasff/phpredis
* @author 尘缘 <130775@qq.com>
*/
@@ -26,7 +28,7 @@ class Redis
'host' => '127.0.0.1',
'port' => 6379,
'password' => '',
'timeout' => false,
'timeout' => 0,
'expire' => false,
'persistent' => false,
'length' => 0,
@@ -48,9 +50,8 @@ class Redis
}
$func = $this->options['persistent'] ? 'pconnect' : 'connect';
$this->handler = new \Redis;
false === $this->options['timeout'] ?
$this->handler->$func($this->options['host'], $this->options['port']) :
$this->handler->$func($this->options['host'], $this->options['port'], $this->options['timeout']);
if ('' != $this->options['password']) {
$this->handler->auth($this->options['password']);
}