Merge pull request #15686 from nextcloud/backport/15685/stable16

[stable16] Allow redis cluster to use password
This commit is contained in:
Morris Jobke 2019-05-22 15:54:19 +02:00 committed by GitHub
commit 36db83a7ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -1160,15 +1160,19 @@ $CONFIG = array(
* which then causes a FileLocked exception.
*
* See https://redis.io/topics/cluster-spec for details about the Redis cluster
*
* Authentication works with phpredis version 4.2.1+. See
* https://github.com/phpredis/phpredis/commit/c5994f2a42b8a348af92d3acb4edff1328ad8ce1
*/
'redis.cluster' => [
'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required
'localhost:7000',
'localhost:7001'
'localhost:7001',
],
'timeout' => 0.0,
'read_timeout' => 0.0,
'failover_mode' => \RedisCluster::FAILOVER_ERROR
'failover_mode' => \RedisCluster::FAILOVER_ERROR,
'password' => '', // Optional, if not defined no password will be used.
],

View File

@ -56,7 +56,11 @@ class RedisFactory {
} else {
$readTimeout = null;
}
if (isset($config['password']) && $config['password'] !== '') {
$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, false, $config['password']);
} else {
$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout);
}
if (isset($config['failover_mode'])) {
$this->instance->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, $config['failover_mode']);