Skip to content

Commit b085133

Browse files
authored
Merge pull request #31451 from nextcloud/backport/30959/stable22
[stable22] use persistent connections when connecting to redis
2 parents 79d8569 + b2eac88 commit b085133

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/private/RedisFactory.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ private function create() {
8888

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

9696
if (isset($config['failover_mode'])) {
@@ -119,9 +119,17 @@ private function create() {
119119
$connectionParameters = [
120120
'stream' => $this->getSslContext($config)
121121
];
122-
$this->instance->connect($host, $port, $timeout, null, 0, $readTimeout, $connectionParameters);
122+
/**
123+
* even though the stubs and documentation don't want you to know this,
124+
* pconnect does have the same $connectionParameters argument connect has
125+
*
126+
* https://github.com/phpredis/phpredis/blob/0264de1824b03fb2d0ad515b4d4ec019cd2dae70/redis.c#L710-L730
127+
*
128+
* @psalm-suppress TooManyArguments
129+
*/
130+
$this->instance->pconnect($host, $port, $timeout, null, 0, $readTimeout, $connectionParameters);
123131
} else {
124-
$this->instance->connect($host, $port, $timeout, null, 0, $readTimeout);
132+
$this->instance->pconnect($host, $port, $timeout, null, 0, $readTimeout);
125133
}
126134

127135

0 commit comments

Comments
 (0)