diff --git a/README.md b/README.md index 3ff3ed4952c0e510ce1726e225eb266100f4ad07..1648bb0db0b1deae494656584bd16a8288d0b635 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 e7a4fee24988f63ede8cca81c02570a7b36615e3..f9fc11cc4bc8628e680acbfccd4cf4475fefd23d 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 991cd7f6382d418108d9a8ebac753a1f52f45c09..747d73a46e07c7e9106436bfa01e19895de5e676 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 fabd620ec63dcab0eddd8e2caa1855ecdbe6b104..e8df702a3ff7d430b9c4963eb2fa8db58809f5d6 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 5aa26bae3bd2a6f841f2b46babaa655401d6affa..982dd75cf04ff803bf3797f2cec0018af1a46aa9 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.