From 453f58d65219ee5de697952bb33ab571d2c2ed33 Mon Sep 17 00:00:00 2001 From: Sascha Grossenbacher <saschagros@gmail.com> Date: Tue, 10 Sep 2019 21:30:48 +0200 Subject: [PATCH] Revert "Issue #2882796 by Dave Reid, anish.a, jmullikin: Add support for persistent connections to redis host" This reverts commit 1576054e8491b811b8c1d46484ecc25f26501831. --- README.md | 7 ------- src/Client/PhpRedis.php | 9 ++------- src/Client/Predis.php | 15 ++++++--------- src/ClientFactory.php | 7 ++----- src/ClientInterface.php | 2 +- 5 files changed, 11 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 3ff3ed4..1648bb0 100644 --- a/README.md +++ b/README.md @@ -141,13 +141,6 @@ If your Redis instance is remote, you can use this syntax: Port is optional, default is 6379 (default Redis port). -Use persistent connections --------------------------- - -This mode needs the following setting: - - $settings['redis.connection']['persistent'] = TRUE; - Using a specific database ------------------------- diff --git a/src/Client/PhpRedis.php b/src/Client/PhpRedis.php index e7a4fee..f9fc11c 100644 --- a/src/Client/PhpRedis.php +++ b/src/Client/PhpRedis.php @@ -14,7 +14,7 @@ class PhpRedis implements ClientInterface { /** * {@inheritdoc} */ - public function getClient($host = NULL, $port = NULL, $base = NULL, $password = NULL, $persistent = FALSE) { + public function getClient($host = NULL, $port = NULL, $base = NULL, $password = NULL) { $client = new \Redis(); // Sentinel mode, get the real master. @@ -25,12 +25,7 @@ class PhpRedis implements ClientInterface { } } - if ($persistent) { - $client->pconnect($host, $port); - } - else { - $client->connect($host, $port); - } + $client->connect($host, $port); if (isset($password)) { $client->auth($password); diff --git a/src/Client/Predis.php b/src/Client/Predis.php index 991cd7f..747d73a 100644 --- a/src/Client/Predis.php +++ b/src/Client/Predis.php @@ -11,13 +11,12 @@ use Predis\Client; */ class Predis implements ClientInterface { - public function getClient($host = NULL, $port = NULL, $base = NULL, $password = NULL, $replicationHosts = NULL, $persistent = FALSE) { + public function getClient($host = NULL, $port = NULL, $base = NULL, $password = NULL, $replicationHosts = NULL) { $connectionInfo = [ 'password' => $password, 'host' => $host, 'port' => $port, - 'database' => $base, - 'persistent' => $persistent + 'database' => $base ]; foreach ($connectionInfo as $key => $value) { @@ -37,15 +36,13 @@ class Predis implements ClientInterface { $parameters = []; foreach ($replicationHosts as $replicationHost) { - $param = 'tcp://' . $replicationHost['host'] . ':' . $replicationHost['port'] - . '?persistent=' . (($persistent) ? 'true' : 'false'); - // Configure master. if ($replicationHost['role'] === 'primary') { - $param .= '&alias=master'; + $parameters[] = 'tcp://' . $replicationHost['host'] . ':' . $replicationHost['port'] . '?alias=master'; + } + else { + $parameters[] = 'tcp://' . $replicationHost['host'] . ':' . $replicationHost['port']; } - - $parameters[] = $param; } $options = ['replication' => true]; diff --git a/src/ClientFactory.php b/src/ClientFactory.php index fabd620..e8df702 100644 --- a/src/ClientFactory.php +++ b/src/ClientFactory.php @@ -150,7 +150,6 @@ class ClientFactory { 'port' => self::REDIS_DEFAULT_PORT, 'base' => self::REDIS_DEFAULT_BASE, 'password' => self::REDIS_DEFAULT_PASSWORD, - 'persistent' => FALSE, ]; // If using replication, lets create the client appropriately. @@ -166,16 +165,14 @@ class ClientFactory { $settings['port'], $settings['base'], $settings['password'], - $settings['replication.host'], - $settings['persistent']); + $settings['replication.host']); } else { self::$_client = self::getClientInterface()->getClient( $settings['host'], $settings['port'], $settings['base'], - $settings['password'], - $settings['persistent']); + $settings['password']); } } diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 5aa26ba..982dd75 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -12,7 +12,7 @@ interface ClientInterface { * @return mixed * Real client depends from the library behind. */ - public function getClient($host = NULL, $port = NULL, $base = NULL, $password = NULL, $persistent = FALSE); + public function getClient($host = NULL, $port = NULL, $base = NULL); /** * Get underlaying library name used. -- GitLab