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,43 +156,48 @@ class RedisConnectionTest extends TestCase
|
||||
$connection->release();
|
||||
}
|
||||
|
||||
private function getDefaultPoolConfig()
|
||||
{
|
||||
return [
|
||||
'host' => 'redis',
|
||||
'auth' => 'redis',
|
||||
'port' => 16379,
|
||||
'read_timeout' => 3.0,
|
||||
'reserved' => null,
|
||||
'retry_interval' => 5,
|
||||
'context' => [
|
||||
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
|
||||
],
|
||||
'pool' => [
|
||||
'min_connections' => 1,
|
||||
'max_connections' => 30,
|
||||
'connect_timeout' => 10.0,
|
||||
'wait_timeout' => 3.0,
|
||||
'heartbeat' => -1,
|
||||
'max_idle_time' => 1,
|
||||
],
|
||||
'cluster' => [
|
||||
'enable' => false,
|
||||
'name' => null,
|
||||
'seeds' => [
|
||||
'127.0.0.1:6379',
|
||||
],
|
||||
'context' => [
|
||||
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
|
||||
],
|
||||
],
|
||||
'sentinel' => [
|
||||
'enable' => false,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getRedisPool()
|
||||
{
|
||||
$container = Mockery::mock(Container::class);
|
||||
$container->shouldReceive('get')->with(ConfigInterface::class)->andReturn(new Config([
|
||||
'redis' => [
|
||||
'default' => [
|
||||
'host' => 'redis',
|
||||
'auth' => 'redis',
|
||||
'port' => 16379,
|
||||
'read_timeout' => 3.0,
|
||||
'reserved' => null,
|
||||
'retry_interval' => 5,
|
||||
'context' => [
|
||||
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
|
||||
],
|
||||
'pool' => [
|
||||
'min_connections' => 1,
|
||||
'max_connections' => 30,
|
||||
'connect_timeout' => 10.0,
|
||||
'wait_timeout' => 3.0,
|
||||
'heartbeat' => -1,
|
||||
'max_idle_time' => 1,
|
||||
],
|
||||
'cluster' => [
|
||||
'enable' => false,
|
||||
'name' => null,
|
||||
'seeds' => [
|
||||
'127.0.0.1:6379',
|
||||
],
|
||||
'context' => [
|
||||
'stream' => ['cafile' => 'foo-cafile', 'verify_peer' => true],
|
||||
],
|
||||
],
|
||||
'sentinel' => [
|
||||
'enable' => false,
|
||||
],
|
||||
],
|
||||
'default' => $this->getDefaultPoolConfig(),
|
||||
],
|
||||
]));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user