From 14e36a22d69ab9e10b5335d8169cffab3d9de789 Mon Sep 17 00:00:00 2001 From: Ferran Vidal Date: Thu, 10 Dec 2020 16:38:46 +0100 Subject: [PATCH] [Cache] Make use of `read_timeout` in `\RedisSentinel` and `\Redis` Both classes have an optional argument `$readTimeout` that can be set during initialization for `\RedisSentinel` and during `connect`/`pconnect` respectively. --- src/Symfony/Component/Cache/Traits/RedisTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 55750f8feb..851ff9832a 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -184,7 +184,7 @@ trait RedisTrait $port = $hosts[0]['port'] ?? null; if (isset($params['redis_sentinel'])) { - $sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']); + $sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout']); if (![$host, $port] = $sentinel->getMasterAddrByName($params['redis_sentinel'])) { throw new InvalidArgumentException(sprintf('Failed to retrieve master information from master name "%s" and address "%s:%d".', $params['redis_sentinel'], $host, $port)); @@ -192,7 +192,7 @@ trait RedisTrait } try { - @$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']); + @$redis->{$connect}($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout']); set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; }); $isConnected = $redis->isConnected();