From c9b2a75b55cad7d475af74c36fbe5b0b42a6f9e3 Mon Sep 17 00:00:00 2001 From: Xiaoyaoking Date: Fri, 10 Mar 2023 14:00:54 +0800 Subject: [PATCH 1/4] Update config.sample.inc.php --- includes/config.sample.inc.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 10ed201..4ee02ac 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' => 'redis://127.0.0.1:7000,redis://127.0.0.1:7001,redis://127.0.0.1:7002,redis://127.0.0.1:7003,redis://127.0.0.1:7004,redis://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 From 436f4a6f2f1da062a1cfdbdb157adc5733725263 Mon Sep 17 00:00:00 2001 From: Xiaoyaoking Date: Fri, 10 Mar 2023 14:02:39 +0800 Subject: [PATCH 2/4] Update common.inc.php --- includes/common.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/common.inc.php b/includes/common.inc.php index ae0bd52..ded799c 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' => $server['host'],'exceptions' => true)); + }else{ + $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']); + } } try { From 748d87f378bf7529915cddba3da3088b7971bbeb Mon Sep 17 00:00:00 2001 From: Xiaoyaoking Date: Fri, 10 Mar 2023 14:12:39 +0800 Subject: [PATCH 3/4] Update config.sample.inc.php --- includes/config.sample.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 4ee02ac..8a14c3c 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -17,7 +17,7 @@ ), array( 'name' => 'cluster server', // Optional name. - 'host' => 'redis://127.0.0.1:7000,redis://127.0.0.1:7001,redis://127.0.0.1:7002,redis://127.0.0.1:7003,redis://127.0.0.1:7004,redis://127.0.0.1:7005', + '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 From 68119847ad3e1feec49ce0c03a431e2097a46ad6 Mon Sep 17 00:00:00 2001 From: Xiaoyaoking Date: Fri, 10 Mar 2023 14:15:31 +0800 Subject: [PATCH 4/4] Update common.inc.php --- includes/common.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/common.inc.php b/includes/common.inc.php index ded799c..2855a26 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -118,7 +118,7 @@ $redis = new Predis\Client(array('scheme' => 'unix', 'path' => $server['path'])); } else { if (isset($server['cluster'])){ //New cluster configuration judgment - $redis = new Predis\Client(array('cluster' => $server['host'],'exceptions' => true)); + $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']); }