Skip to content

Commit cbefb81

Browse files
authored
Connect to RedisCluster with password auth
Currently it is not possible to connect to RedisCluster with password. AUTH param is described in documentation (last example) https://symfony.com/doc/current/components/cache/adapters/redis_adapter.html#configure-the-connection but totally ignored in the code and connection fails ``` RedisAdapter::createConnection( 'redis:?host[localhost]&host[localhost:6379]&host[/var/run/redis.sock:]&auth=my-password&redis_cluster=1' ); ``` See RedisCluster usage here https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#declaring-a-cluster-with-an-array-of-seeds
1 parent 8a7c776 commit cbefb81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static function createConnection($dsn, array $options = [])
228228
}
229229

230230
try {
231-
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']);
231+
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent'], $params['auth'] ?? '');
232232
} catch (\RedisClusterException $e) {
233233
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
234234
}

0 commit comments

Comments
 (0)