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

Skip to content

Commit 05c319f

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 05c319f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/Cache/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
* added sub-second expiry accuracy for backends that support it
1010
* added support for phpredis 4 `compression` and `tcp_keepalive` options
1111
* added automatic table creation when using Doctrine DBAL with PDO-based backends
12+
* added support for a `predis_options` query parameter array in the redis dsn.
1213
* throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
1314
* deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead
1415
* deprecated the `AbstractAdapter::createSystemCache()` method

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ public static function createConnection($dsn, array $options = array())
167167
$params['scheme'] = $scheme;
168168
$params['database'] = $params['dbindex'] ?: null;
169169
$params['password'] = $auth;
170-
$redis = new $class((new Factory())->create($params));
170+
171+
$predisOptions = false !== isset($params['predis_options']) && true === \is_array($params['predis_options']) ? $params['predis_options'] : array();
172+
173+
$redis = new $class((new Factory())->create($params), $predisOptions);
171174
} elseif (class_exists($class, false)) {
172175
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Redis" or "Predis\Client"', $class));
173176
} else {

0 commit comments

Comments
 (0)
0