diff --git a/includes/common.inc.php b/includes/common.inc.php index ae0bd52..2855a26 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -117,7 +117,11 @@ if(isset($server['scheme']) && $server['scheme'] === 'unix' && $server['path']) { $redis = new Predis\Client(array('scheme' => 'unix', 'path' => $server['path'])); } else { - $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']); + if (isset($server['cluster'])){ //New cluster configuration judgment + $redis = new Predis\Client(array('cluster' => 'redis://'.implode(',redis://', $server['host']),'exceptions' => true)); + }else{ + $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']); + } } try { diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 10ed201..8a14c3c 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -15,7 +15,18 @@ // Optional Redis authentication. //'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server. ), + array( + 'name' => 'cluster server', // Optional name. + 'host' => ['127.0.0.1:7000','127.0.0.1:7001','127.0.0.1:7002','127.0.0.1:7003','127.0.0.1:7004','127.0.0.1:7005'], + 'cluster' => true, + 'filter' => '*', + 'scheme' => 'tcp', // Optional. Connection scheme. 'tcp' - for TCP connection, 'unix' - for connection by unix domain socket + 'path' => '', // Optional. Path to unix domain socket. Uses only if 'scheme' => 'unix'. Example: '/var/run/redis/redis.sock' + 'hide' => false, // Optional. Override global setting. Hide empty databases in the database list. + // Optional Redis authentication. + //'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server. + ), /*array( 'host' => 'localhost', 'port' => 6380