Skip to content

Commit 7acca31

Browse files
[Cache] fix setting "read_timeout" when using Redis
1 parent f4a02b4 commit 7acca31

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static function createConnection($dsn, array $options = [])
176176

177177
$initializer = static function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
178178
try {
179-
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
179+
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout']);
180180

181181
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
182182
$isConnected = $redis->isConnected();
@@ -188,7 +188,6 @@ public static function createConnection($dsn, array $options = [])
188188

189189
if ((null !== $auth && !$redis->auth($auth))
190190
|| ($params['dbindex'] && !$redis->select($params['dbindex']))
191-
|| ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout']))
192191
) {
193192
$e = preg_replace('/^ERR /', '', $redis->getLastError());
194193
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e.'.');
@@ -215,6 +214,7 @@ public static function createConnection($dsn, array $options = [])
215214
}
216215
$params['lazy_connect'] = $params['lazy'] ?? true;
217216
$params['connect_timeout'] = $params['timeout'];
217+
$params['read_timeout'] = $params['read_timeout'];
218218

219219
try {
220220
$redis = new $class($hosts, $params);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy