mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
优化 redis connect time, redis扩展已兼容time参数
This commit is contained in:
9
library/think/cache/driver/Redis.php
vendored
9
library/think/cache/driver/Redis.php
vendored
@@ -15,7 +15,9 @@ use think\Cache;
|
|||||||
use think\Exception;
|
use think\Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis缓存驱动
|
* Redis缓存驱动,适合单机部署、有前端代理实现高可用的场景,性能最好
|
||||||
|
* 有需要在业务层实现读写分离、或者使用RedisCluster的需求,请使用Redisd驱动
|
||||||
|
*
|
||||||
* 要求安装phpredis扩展:https://github.com/nicolasff/phpredis
|
* 要求安装phpredis扩展:https://github.com/nicolasff/phpredis
|
||||||
* @author 尘缘 <130775@qq.com>
|
* @author 尘缘 <130775@qq.com>
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +28,7 @@ class Redis
|
|||||||
'host' => '127.0.0.1',
|
'host' => '127.0.0.1',
|
||||||
'port' => 6379,
|
'port' => 6379,
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'timeout' => false,
|
'timeout' => 0,
|
||||||
'expire' => false,
|
'expire' => false,
|
||||||
'persistent' => false,
|
'persistent' => false,
|
||||||
'length' => 0,
|
'length' => 0,
|
||||||
@@ -48,9 +50,8 @@ class Redis
|
|||||||
}
|
}
|
||||||
$func = $this->options['persistent'] ? 'pconnect' : 'connect';
|
$func = $this->options['persistent'] ? 'pconnect' : 'connect';
|
||||||
$this->handler = new \Redis;
|
$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']);
|
$this->handler->$func($this->options['host'], $this->options['port'], $this->options['timeout']);
|
||||||
|
|
||||||
if ('' != $this->options['password']) {
|
if ('' != $this->options['password']) {
|
||||||
$this->handler->auth($this->options['password']);
|
$this->handler->auth($this->options['password']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user