diff --git a/library/think/cache/driver/Apc.php b/library/think/cache/driver/Apc.php index ebe163cc..b622762a 100644 --- a/library/think/cache/driver/Apc.php +++ b/library/think/cache/driver/Apc.php @@ -23,7 +23,6 @@ class Apc protected $options = [ 'expire' => 0, 'prefix' => '', - 'length' => 0, ]; /***************************** 需要支持apc_cli模式 diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index d8487102..267fabdd 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -25,7 +25,6 @@ class File 'cache_subdir' => false, 'path_level' => 1, 'prefix' => '', - 'length' => 0, 'path' => CACHE_PATH, 'data_compress' => false, ]; diff --git a/library/think/cache/driver/Memcache.php b/library/think/cache/driver/Memcache.php index fbfbb08a..370c6415 100644 --- a/library/think/cache/driver/Memcache.php +++ b/library/think/cache/driver/Memcache.php @@ -23,7 +23,6 @@ class Memcache 'expire' => 0, 'timeout' => 0, // 超时时间(单位:毫秒) 'persistent' => true, - 'length' => 0, 'prefix' => '', ]; diff --git a/library/think/cache/driver/Memcached.php b/library/think/cache/driver/Memcached.php index f82500f5..e413b06f 100644 --- a/library/think/cache/driver/Memcached.php +++ b/library/think/cache/driver/Memcached.php @@ -22,7 +22,6 @@ class Memcached 'port' => 11211, 'expire' => 0, 'timeout' => 0, // 超时时间(单位:毫秒) - 'length' => 0, 'prefix' => '', ]; diff --git a/library/think/cache/driver/Redis.php b/library/think/cache/driver/Redis.php index 23455a1d..403229ff 100644 --- a/library/think/cache/driver/Redis.php +++ b/library/think/cache/driver/Redis.php @@ -17,7 +17,7 @@ use think\Exception; /** * Redis缓存驱动,适合单机部署、有前端代理实现高可用的场景,性能最好 * 有需要在业务层实现读写分离、或者使用RedisCluster的需求,请使用Redisd驱动 - * + * * 要求安装phpredis扩展:https://github.com/nicolasff/phpredis * @author 尘缘 <130775@qq.com> */ @@ -31,7 +31,6 @@ class Redis 'timeout' => 0, 'expire' => 0, 'persistent' => false, - 'length' => 0, 'prefix' => '', ]; diff --git a/library/think/cache/driver/Redisd.php b/library/think/cache/driver/Redisd.php index 67058975..d32dbaca 100644 --- a/library/think/cache/driver/Redisd.php +++ b/library/think/cache/driver/Redisd.php @@ -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 diff --git a/library/think/cache/driver/Sae.php b/library/think/cache/driver/Sae.php index 4bead286..03b70735 100644 --- a/library/think/cache/driver/Sae.php +++ b/library/think/cache/driver/Sae.php @@ -27,7 +27,6 @@ class Sae 'expire' => 0, 'timeout' => false, 'persistent' => false, - 'length' => 0, 'prefix' => '', ]; diff --git a/library/think/cache/driver/Secache.php b/library/think/cache/driver/Secache.php index 13613bfe..67966f21 100644 --- a/library/think/cache/driver/Secache.php +++ b/library/think/cache/driver/Secache.php @@ -25,7 +25,6 @@ class Secache 'path' => '', 'expire' => 0, 'prefix' => '', - 'length' => 0, ]; /** diff --git a/library/think/cache/driver/Sqlite.php b/library/think/cache/driver/Sqlite.php index 89a24e96..6144a366 100644 --- a/library/think/cache/driver/Sqlite.php +++ b/library/think/cache/driver/Sqlite.php @@ -26,7 +26,6 @@ class Sqlite implements CacheInterface 'table' => 'sharedmemory', 'prefix' => '', 'expire' => 0, - 'length' => 0, 'persistent' => false, ]; diff --git a/library/think/cache/driver/Wincache.php b/library/think/cache/driver/Wincache.php index e77b53a2..66972a48 100644 --- a/library/think/cache/driver/Wincache.php +++ b/library/think/cache/driver/Wincache.php @@ -23,7 +23,6 @@ class Wincache protected $options = [ 'prefix' => '', 'expire' => 0, - 'length' => 0, ]; /** diff --git a/library/think/cache/driver/Xcache.php b/library/think/cache/driver/Xcache.php index 00a0483f..3fea3296 100644 --- a/library/think/cache/driver/Xcache.php +++ b/library/think/cache/driver/Xcache.php @@ -23,7 +23,6 @@ class Xcache protected $options = [ 'prefix' => '', 'expire' => 0, - 'length' => 0, ]; /**