Added getConfig for redisPool (#6674)

This commit is contained in:
宣言就是Siam 2024-04-11 18:18:35 +08:00 committed by GitHub
parent c139faa508
commit 2809b6ba5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 55 additions and 32 deletions

View File

@ -1,5 +1,9 @@
# v3.1.18 - TBD
## Added
- [#6674](https://github.com/hyperf/hyperf/pull/6674) Added getConfig for redisPool.
## Fixed
- [#6664](https://github.com/hyperf/hyperf/pull/6664) Fixed bug that `isset` cannot check `null` in `Hyperf\Collection\Collection`.

View File

@ -48,6 +48,11 @@ class RedisPool extends Pool
return $this->name;
}
public function getConfig(): array
{
return $this->config;
}
protected function createConnection(): ConnectionInterface
{
return new RedisConnection($this->container, $this, $this->config);

View File

@ -92,6 +92,15 @@ class RedisConnectionTest extends TestCase
], $config);
}
public function testRedisPoolConfig()
{
$pool = $this->getRedisPool();
$config = $pool->getConfig();
$this->assertSame($this->getDefaultPoolConfig(), $config);
}
public function testRedisConnectionReconnect()
{
$pool = $this->getRedisPool();
@ -147,12 +156,9 @@ class RedisConnectionTest extends TestCase
$connection->release();
}
private function getRedisPool()
private function getDefaultPoolConfig()
{
$container = Mockery::mock(Container::class);
$container->shouldReceive('get')->with(ConfigInterface::class)->andReturn(new Config([
'redis' => [
'default' => [
return [
'host' => 'redis',
'auth' => 'redis',
'port' => 16379,
@ -183,7 +189,15 @@ class RedisConnectionTest extends TestCase
'sentinel' => [
'enable' => false,
],
],
];
}
private function getRedisPool()
{
$container = Mockery::mock(Container::class);
$container->shouldReceive('get')->with(ConfigInterface::class)->andReturn(new Config([
'redis' => [
'default' => $this->getDefaultPoolConfig(),
],
]));