Skip to content

Commit de189a4

Browse files
janikaja-tetclaudeostrolucky
authored
fix(phpredis): honor initial read timeout (#764)
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Gabriel Ostrolucký <gabriel.ostrolucky@gmail.com>
1 parent b3bc736 commit de189a4

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/Factory/PhpredisClientFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ private function createClient(RedisDsn $dsn, string $class, string $alias, array
346346
$dsn->getPort(),
347347
$options['connection_timeout'],
348348
$persistentId,
349-
5, // retry interval
350-
5, // read timeout
349+
(int) ($options['read_write_timeout'] ?? 5), // retry interval
350+
$options['read_write_timeout'] ?? 5, // read timeout
351351
$context,
352352
];
353353

tests/Factory/PhpredisClientFactoryTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,10 @@ public function testMethodWithPassByRefArgument(): void
534534

535535
public function testCreateWithConnectionPersistentTrue(): void
536536
{
537+
$this->logger->method('debug')->with(...$this->withConsecutive(
538+
['Executing command "PCONNECT localhost 6379 5 default 1 1.5"'],
539+
));
540+
537541
$factory = new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger));
538542

539543
$client = $factory->create(
@@ -542,9 +546,10 @@ public function testCreateWithConnectionPersistentTrue(): void
542546
[
543547
'connection_timeout' => 5,
544548
'connection_persistent' => true,
549+
'read_write_timeout' => 1.5,
545550
],
546551
'default',
547-
false,
552+
true,
548553
);
549554

550555
$this->assertInstanceOf(Redis::class, $client);
@@ -572,6 +577,10 @@ public function testCreateWithConnectionPersistentString(): void
572577

573578
public function testCreateWithConnectionPersistentFalse(): void
574579
{
580+
$this->logger->method('debug')->with(...$this->withConsecutive(
581+
['Executing command "CONNECT localhost 6379 5 <null> 1 1.5"'],
582+
));
583+
575584
$factory = new PhpredisClientFactory(new RedisCallInterceptor($this->redisLogger));
576585

577586
$client = $factory->create(
@@ -580,9 +589,10 @@ public function testCreateWithConnectionPersistentFalse(): void
580589
[
581590
'connection_timeout' => 5,
582591
'connection_persistent' => false,
592+
'read_write_timeout' => 1.5,
583593
],
584594
'default',
585-
false,
595+
true,
586596
);
587597

588598
$this->assertInstanceOf(Redis::class, $client);

0 commit comments

Comments
 (0)