去掉缓存驱动的length参数

This commit is contained in:
thinkphp
2016-06-03 12:20:18 +08:00
parent e37cf2cc17
commit f05e7427d9
11 changed files with 16 additions and 27 deletions

View File

@@ -18,21 +18,21 @@ use think\Log;
/**
配置参数:
'cache' => [
'type' => 'Redisd'
'host' => 'A:6379,B:6379', //redis服务器ip多台用逗号隔开读写分离开启时默认写A当A主挂时再尝试写B
'slave' => 'B:6379,C:6379', //redis服务器ip多台用逗号隔开读写分离开启时所有IP随机读其中一台挂时尝试读其它节点可以配置权重
'port' => 6379, //默认的端口号
'password' => '', //AUTH认证密码当redis服务直接暴露在外网时推荐
'timeout' => 10, //连接超时时间
'expire' => false, //默认过期时间,默认为永不过期
'prefix' => '', //缓存前缀,不宜过长
'persistent' => false, //是否长连接 false=短连接,推荐长连接
'type' => 'Redisd'
'host' => 'A:6379,B:6379', //redis服务器ip多台用逗号隔开读写分离开启时默认写A当A主挂时再尝试写B
'slave' => 'B:6379,C:6379', //redis服务器ip多台用逗号隔开读写分离开启时所有IP随机读其中一台挂时尝试读其它节点可以配置权重
'port' => 6379, //默认的端口号
'password' => '', //AUTH认证密码当redis服务直接暴露在外网时推荐
'timeout' => 10, //连接超时时间
'expire' => false, //默认过期时间,默认为永不过期
'prefix' => '', //缓存前缀,不宜过长
'persistent' => false, //是否长连接 false=短连接,推荐长连接
],
单例获取:
$redis = \think\Cache::connect(Config::get('cache'));
$redis->master(true)->setnx('key');
$redis->master(false)->get('key');
$redis = \think\Cache::connect(Config::get('cache'));
$redis->master(true)->setnx('key');
$redis->master(false)->get('key');
*/
/**
@@ -70,7 +70,6 @@ class Redisd
'timeout' => 10,
'expire' => false,
'persistent' => false,
'length' => 0,
'prefix' => '',
'serialize' => \Redis::SERIALIZER_PHP,
];
@@ -136,7 +135,7 @@ class Redisd
//发生错误则摘掉当前节点
try {
$result = $this->handler->$func($host, $port, $this->options['timeout']);
if($result === false) {
if (false === $result) {
$this->handler->getLastError();
}
@@ -145,7 +144,7 @@ class Redisd
}
$this->handler->setOption(\Redis::OPT_SERIALIZER, $this->options['serialize']);
if(strlen($this->options['prefix'])) {
if (strlen($this->options['prefix'])) {
$this->handler->setOption(\Redis::OPT_PREFIX, $this->options['prefix']);
}
@@ -288,7 +287,7 @@ class Redisd
$this->master(true);
return $this->handler->flushDB();
}
/**
* 返回句柄对象,可执行其它高级方法
* 需要先执行 $redis->master() 连接到 DB