aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2024-07-25 20:14:08 +0200
committerGitHub <noreply@github.com>2024-07-25 20:14:08 +0200
commite827b86b0974586e4677a0bea152d2f1f9943f26 (patch)
tree323c8d518ad0bf6a01902206a91fa8b007fcaf4b /lib
parenta80d72683f891dcc1e09e25ec678b1262fd703ef (diff)
parent692f4fa51c6a127d03d45f87afefd7eae604475d (diff)
downloadnextcloud-server-e827b86b0974586e4677a0bea152d2f1f9943f26.tar.gz
nextcloud-server-e827b86b0974586e4677a0bea152d2f1f9943f26.zip
Merge pull request #46684 from nextcloud/backport/46674/stable29
[stable29] feat: add config flag to toggle persistent redis connections
Diffstat (limited to 'lib')
-rw-r--r--lib/private/RedisFactory.php33
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/private/RedisFactory.php b/lib/private/RedisFactory.php
index 4903a8713df..6a56a8eab47 100644
--- a/lib/private/RedisFactory.php
+++ b/lib/private/RedisFactory.php
@@ -74,6 +74,7 @@ class RedisFactory {
// # TLS support
// # https://github.com/phpredis/phpredis/issues/1600
$connectionParameters = $this->getSslContext($config);
+ $persistent = $this->config->getValue('redis.persistent', true);
// cluster config
if ($isCluster) {
@@ -83,9 +84,9 @@ class RedisFactory {
// Support for older phpredis versions not supporting connectionParameters
if ($connectionParameters !== null) {
- $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, true, $auth, $connectionParameters);
+ $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, $persistent, $auth, $connectionParameters);
} else {
- $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, true, $auth);
+ $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, $persistent, $auth);
}
if (isset($config['failover_mode'])) {
@@ -104,17 +105,25 @@ class RedisFactory {
$connectionParameters = [
'stream' => $this->getSslContext($config)
];
- /**
- * 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);
+ if ($persistent) {
+ /**
+ * 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, $connectionParameters);
+ }
} else {
- $this->instance->pconnect($host, $port, $timeout, null, 0, $readTimeout);
+ if ($persistent) {
+ $this->instance->pconnect($host, $port, $timeout, null, 0, $readTimeout);
+ } else {
+ $this->instance->connect($host, $port, $timeout, null, 0, $readTimeout);
+ }
}