Skip to content

Commit

Permalink
Merge pull request #31451 from nextcloud/backport/30959/stable22
Browse files Browse the repository at this point in the history
[stable22] use persistent connections when connecting to redis
  • Loading branch information
PVince81 authored Mar 4, 2022
2 parents 79d8569 + b2eac88 commit b085133
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/private/RedisFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ private function create() {

// Support for older phpredis versions not supporting connectionParameters
if ($connectionParameters !== null) {
$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, false, $auth, $connectionParameters);
$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, true, $auth, $connectionParameters);
} else {
$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, false, $auth);
$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, true, $auth);
}

if (isset($config['failover_mode'])) {
Expand Down Expand Up @@ -119,9 +119,17 @@ private function create() {
$connectionParameters = [
'stream' => $this->getSslContext($config)
];
$this->instance->connect($host, $port, $timeout, null, 0, $readTimeout, $connectionParameters);
/**
* even though the stubs and documentation don't want you to know this,
* pconnect does have the same $connectionParameters argument connect has
*
* https://github.com/phpredis/phpredis/blob/0264de1824b03fb2d0ad515b4d4ec019cd2dae70/redis.c#L710-L730
*
* @psalm-suppress TooManyArguments
*/
$this->instance->pconnect($host, $port, $timeout, null, 0, $readTimeout, $connectionParameters);
} else {
$this->instance->connect($host, $port, $timeout, null, 0, $readTimeout);
$this->instance->pconnect($host, $port, $timeout, null, 0, $readTimeout);
}


Expand Down

0 comments on commit b085133

Please sign in to comment.