Skip to content

Commit cca33e1

Browse files
committed
Merge branch 'master' into 2.1-merge
2 parents 7ad12b4 + 4ff096b commit cca33e1

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/RedisConnection.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class RedisConnection extends BaseConnection implements ConnectionInterface
4343
'enable' => false,
4444
'name' => null,
4545
'seeds' => [],
46+
'read_timeout' => 0.0,
47+
'persistent' => false,
4648
],
4749
'sentinel' => [
4850
'enable' => false,
@@ -63,7 +65,7 @@ class RedisConnection extends BaseConnection implements ConnectionInterface
6365
public function __construct(ContainerInterface $container, Pool $pool, array $config)
6466
{
6567
parent::__construct($container, $pool);
66-
$this->config = array_replace($this->config, $config);
68+
$this->config = array_replace_recursive($this->config, $config);
6769

6870
$this->reconnect();
6971
}
@@ -122,7 +124,7 @@ public function reconnect(): bool
122124
$redis->setOption($name, $value);
123125
}
124126

125-
if (isset($auth) && $auth !== '') {
127+
if ($redis instanceof \Redis && isset($auth) && $auth !== '') {
126128
$redis->auth($auth);
127129
}
128130

@@ -164,9 +166,12 @@ protected function createRedisCluster()
164166
try {
165167
$seeds = $this->config['cluster']['seeds'] ?? [];
166168
$name = $this->config['cluster']['name'] ?? null;
169+
$readTimeout = $this->config['cluster']['read_timeout'] ?? 0.0;
170+
$persistent = $this->config['cluster']['persistent'] ?? false;
167171
$timeout = $this->config['timeout'] ?? null;
172+
$auth = $this->config['auth'] ?? null;
168173

169-
$redis = new \RedisCluster($name, $seeds, $timeout);
174+
$redis = new \RedisCluster($name, $seeds, $timeout, $readTimeout, $persistent, $auth);
170175
} catch (\Throwable $e) {
171176
throw new ConnectionException('Connection reconnect failed ' . $e->getMessage());
172177
}

tests/RedisConnectionTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public function testRedisConnectionConfig()
4949
'cluster' => [
5050
'enable' => false,
5151
'name' => null,
52-
'seeds' => [],
52+
'seeds' => [
53+
'127.0.0.1:6379',
54+
],
55+
'read_timeout' => 0.0,
56+
'persistent' => false,
5357
],
5458
'sentinel' => [
5559
'enable' => false,
@@ -126,6 +130,16 @@ private function getRedisPool()
126130
'heartbeat' => -1,
127131
'max_idle_time' => 1,
128132
],
133+
'cluster' => [
134+
'enable' => false,
135+
'name' => null,
136+
'seeds' => [
137+
'127.0.0.1:6379',
138+
],
139+
],
140+
'sentinel' => [
141+
'enable' => false,
142+
],
129143
],
130144
],
131145
]));

0 commit comments

Comments
 (0)