Skip to content
Snippets Groups Projects
Commit 453f58d6 authored by Sascha Grossenbacher's avatar Sascha Grossenbacher
Browse files

Revert "Issue #2882796 by Dave Reid, anish.a, jmullikin: Add support for...

Revert "Issue #2882796 by Dave Reid, anish.a, jmullikin: Add support for persistent connections to redis host"

This reverts commit 1576054e.
parent 3b8354f3
Branches
Tags 8.x-1.2
No related merge requests found
...@@ -141,13 +141,6 @@ If your Redis instance is remote, you can use this syntax: ...@@ -141,13 +141,6 @@ If your Redis instance is remote, you can use this syntax:
Port is optional, default is 6379 (default Redis port). 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 Using a specific database
------------------------- -------------------------
......
...@@ -14,7 +14,7 @@ class PhpRedis implements ClientInterface { ...@@ -14,7 +14,7 @@ class PhpRedis implements ClientInterface {
/** /**
* {@inheritdoc} * {@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(); $client = new \Redis();
// Sentinel mode, get the real master. // Sentinel mode, get the real master.
...@@ -25,12 +25,7 @@ class PhpRedis implements ClientInterface { ...@@ -25,12 +25,7 @@ class PhpRedis implements ClientInterface {
} }
} }
if ($persistent) { $client->connect($host, $port);
$client->pconnect($host, $port);
}
else {
$client->connect($host, $port);
}
if (isset($password)) { if (isset($password)) {
$client->auth($password); $client->auth($password);
......
...@@ -11,13 +11,12 @@ use Predis\Client; ...@@ -11,13 +11,12 @@ use Predis\Client;
*/ */
class Predis implements ClientInterface { 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 = [ $connectionInfo = [
'password' => $password, 'password' => $password,
'host' => $host, 'host' => $host,
'port' => $port, 'port' => $port,
'database' => $base, 'database' => $base
'persistent' => $persistent
]; ];
foreach ($connectionInfo as $key => $value) { foreach ($connectionInfo as $key => $value) {
...@@ -37,15 +36,13 @@ class Predis implements ClientInterface { ...@@ -37,15 +36,13 @@ class Predis implements ClientInterface {
$parameters = []; $parameters = [];
foreach ($replicationHosts as $replicationHost) { foreach ($replicationHosts as $replicationHost) {
$param = 'tcp://' . $replicationHost['host'] . ':' . $replicationHost['port']
. '?persistent=' . (($persistent) ? 'true' : 'false');
// Configure master. // Configure master.
if ($replicationHost['role'] === 'primary') { 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]; $options = ['replication' => true];
......
...@@ -150,7 +150,6 @@ class ClientFactory { ...@@ -150,7 +150,6 @@ class ClientFactory {
'port' => self::REDIS_DEFAULT_PORT, 'port' => self::REDIS_DEFAULT_PORT,
'base' => self::REDIS_DEFAULT_BASE, 'base' => self::REDIS_DEFAULT_BASE,
'password' => self::REDIS_DEFAULT_PASSWORD, 'password' => self::REDIS_DEFAULT_PASSWORD,
'persistent' => FALSE,
]; ];
// If using replication, lets create the client appropriately. // If using replication, lets create the client appropriately.
...@@ -166,16 +165,14 @@ class ClientFactory { ...@@ -166,16 +165,14 @@ class ClientFactory {
$settings['port'], $settings['port'],
$settings['base'], $settings['base'],
$settings['password'], $settings['password'],
$settings['replication.host'], $settings['replication.host']);
$settings['persistent']);
} }
else { else {
self::$_client = self::getClientInterface()->getClient( self::$_client = self::getClientInterface()->getClient(
$settings['host'], $settings['host'],
$settings['port'], $settings['port'],
$settings['base'], $settings['base'],
$settings['password'], $settings['password']);
$settings['persistent']);
} }
} }
......
...@@ -12,7 +12,7 @@ interface ClientInterface { ...@@ -12,7 +12,7 @@ interface ClientInterface {
* @return mixed * @return mixed
* Real client depends from the library behind. * 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. * Get underlaying library name used.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment