Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ab66af

Browse files
committed
[Cache] fix using multiple Redis Sentinel hosts when the first one is not resolvable
1 parent fcb754a commit 4ab66af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ public static function createConnection(string $dsn, array $options = [])
217217
}
218218
$sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra);
219219

220-
if ($address = $sentinel->getMasterAddrByName($params['redis_sentinel'])) {
221-
[$host, $port] = $address;
220+
try {
221+
if ($address = $sentinel->getMasterAddrByName($params['redis_sentinel'])) {
222+
[$host, $port] = $address;
223+
}
224+
} catch (\RedisException $e) {
222225
}
223226
} while (++$hostIndex < \count($hosts) && !$address);
224227

0 commit comments

Comments
 (0)