Skip to content

Commit

Permalink
Revert "Issue #2882796 by Dave Reid, anish.a, jmullikin: Add support …
Browse files Browse the repository at this point in the history
…for persistent connections to redis host"

This reverts commit 1576054.
  • Loading branch information
Berdir committed Sep 10, 2019
1 parent 3b8354f commit 453f58d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 29 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------

Expand Down
9 changes: 2 additions & 7 deletions src/Client/PhpRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -25,12 +25,7 @@ public function getClient($host = NULL, $port = NULL, $base = NULL, $password =
}
}

if ($persistent) {
$client->pconnect($host, $port);
}
else {
$client->connect($host, $port);
}
$client->connect($host, $port);

if (isset($password)) {
$client->auth($password);
Expand Down
15 changes: 6 additions & 9 deletions src/Client/Predis.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
*/
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) {
Expand All @@ -37,15 +36,13 @@ public function getClient($host = NULL, $port = NULL, $base = NULL, $password =
$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];
Expand Down
7 changes: 2 additions & 5 deletions src/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public static function getClient() {
'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.
Expand All @@ -166,16 +165,14 @@ public static function getClient() {
$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']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 453f58d

Please sign in to comment.