8000 [Cache] Add ability to configure predis client. · symfony/symfony@809135d · GitHub
[go: up one dir, main page]

Skip to content

Commit 809135d

Browse files
committed
[Cache] Add ability to configure predis client.
When the predis driver is created, there is no current way to configure the predis client options (such as setting the cluster mode to redis). This merge allows you to add a predis_options parameter to the dsn to allow configuration of options.
1 parent 00e8b49 commit 809135d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Cache\Traits;
1313

14+
use function is_array;
1415
use Predis\Connection\Aggregate\ClusterInterface;
1516
use Predis\Connection\Aggregate\PredisCluster;
1617
use Predis\Connection\Aggregate\RedisCluster;
@@ -167,7 +168,10 @@ public static function createConnection($dsn, array $options = array())
167168
$params['scheme'] = $scheme;
168169
$params['database'] = $params['dbindex'] ?: null;
169170
$params['password'] = $auth;
170-
$redis = new $class((new Factory())->create($params));
171+
172+
$predisOptions = false !== isset($params['predis_options']) && true === is_array($params['predis_options']) ? $params['predis_options'] : [];
173+
174+
$redis = new $class((new Factory())->create($params), $predisOptions);
171175
} elseif (class_exists($class, false)) {
172176
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Redis" or "Predis\Client"', $class));
173177
} else {

0 commit comments

Comments
 (0)
0