mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Added getConfig for redisPool (#6674)
This commit is contained in:
parent
c139faa508
commit
2809b6ba5d
@ -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`.
|
||||
|
@ -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);
|
||||
|
@ -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(),
|
||||
],
|
||||
]));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user