Skip to content

Commit 85bea22

Browse files
authored
Added getConfig for redisPool (#6674)
1 parent 5cf164c commit 85bea22

File tree

2 files changed

+51
-32
lines changed

2 files changed

+51
-32
lines changed

src/Pool/RedisPool.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function getName(): string
4848
return $this->name;
4949
}
5050

51+
public function getConfig(): array
52+
{
53+
return $this->config;
54+
}
55+
5156
protected function createConnection(): ConnectionInterface
5257
{
5358
return new RedisConnection($this->container, $this, $this->config);

tests/RedisConnectionTest.php

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ public function testRedisConnectionConfig()
9292
], $config);
9393
}
9494

95+
public function testRedisPoolConfig()
96+
{
97+
$pool = $this->getRedisPool();
98+
99+
$config = $pool->getConfig();
100+
101+
$this->assertSame($this->getDefaultPoolConfig(), $config);
102+
}
103+
95104
public function testRedisConnectionReconnect()
96105
{
97106
$pool = $this->getRedisPool();
@@ -147,43 +156,48 @@ public function testRedisCloseInLowFrequency()
147156
$connection->release();
148157
}
149158

159+
private function getDefaultPoolConfig()
160+
{
161+
return [
162+
'host' => 'redis',
163+
'auth' => 'redis',
164+
'port' => 16379,
165+
'read_timeout' => 3.0,
166+
'reserved' => null,
167+
'retry_interval' => 5,
168+
'context' => [
169+
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
170+
],
171+
'pool' => [
172+
'min_connections' => 1,
173+
'max_connections' => 30,
174+
'connect_timeout' => 10.0,
175+
'wait_timeout' => 3.0,
176+
'heartbeat' => -1,
177+
'max_idle_time' => 1,
178+
],
179+
'cluster' => [
180+
'enable' => false,
181+
'name' => null,
182+
'seeds' => [
183+
'127.0.0.1:6379',
184+
],
185+
'context' => [
186+
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
187+
],
188+
],
189+
'sentinel' => [
190+
'enable' => false,
191+
],
192+
];
193+
}
194+
150195
private function getRedisPool()
151196
{
152197
$container = Mockery::mock(Container::class);
153198
$container->shouldReceive('get')->with(ConfigInterface::class)->andReturn(new Config([
154199
'redis' => [
155-
'default' => [
156-
'host' => 'redis',
157-
'auth' => 'redis',
158-
'port' => 16379,
159-
'read_timeout' => 3.0,
160-
'reserved' => null,
161-
'retry_interval' => 5,
162-
'context' => [
163-
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
164-
],
165-
'pool' => [
166-
'min_connections' => 1,
167-
'max_connections' => 30,
168-
'connect_timeout' => 10.0,
169-
'wait_timeout' => 3.0,
170-
'heartbeat' => -1,
171-
'max_idle_time' => 1,
172-
],
173-
'cluster' => [
174-
'enable' => false,
175-
'name' => null,
176-
'seeds' => [
177-
'127.0.0.1:6379',
178-
],
179-
'context' => [
180-
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
181-
],
182-
],
183-
'sentinel' => [
184-
'enable' => false,
185-
],
186-
],
200+
'default' => $this->getDefaultPoolConfig(),
187201
],
188202
]));
189203

0 commit comments

Comments
 (0)