From 0332e59f84dfabaca183bb0860ebfe299857e620 Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Wed, 23 Apr 2025 16:32:43 +0800 Subject: [PATCH 1/2] chore: bump version to 0.1.6 --- src/foundation/src/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/foundation/src/Application.php b/src/foundation/src/Application.php index 972088506..3147df81b 100644 --- a/src/foundation/src/Application.php +++ b/src/foundation/src/Application.php @@ -31,7 +31,7 @@ class Application extends Container implements ApplicationContract * * @var string */ - public const VERSION = '0.1.5'; + public const VERSION = '0.1.6'; /** * The base path for the Hypervel installation. From 8a195e8979c4a898ec5644b51b3e504c26826420 Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Thu, 24 Apr 2025 11:40:22 +0800 Subject: [PATCH 2/2] improve: close redis connection while destroying Subscriber object --- src/core/src/Redis/Subscriber.php | 5 +++++ tests/Core/RedisSubscriberTest.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/core/src/Redis/Subscriber.php b/src/core/src/Redis/Subscriber.php index 0a83fcf07..68b4d7a04 100644 --- a/src/core/src/Redis/Subscriber.php +++ b/src/core/src/Redis/Subscriber.php @@ -63,4 +63,9 @@ public function psubscribe(array|string $channels, Closure $callback): void throw new SocketException('Redis connection is disconnected abnormally.'); } } + + public function __destruct() + { + $this->subscriber->close(); + } } diff --git a/tests/Core/RedisSubscriberTest.php b/tests/Core/RedisSubscriberTest.php index aa49035f5..d3f9c1330 100644 --- a/tests/Core/RedisSubscriberTest.php +++ b/tests/Core/RedisSubscriberTest.php @@ -45,6 +45,9 @@ public function testSubscribe() ->twice() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = true; $subscriber = new Subscriber($config, $mockRedisSubscriber); @@ -83,6 +86,9 @@ public function testSubscribeThrowsExceptionWhenConnectionClosedAbnormally() ->once() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = false; $subscriber = new Subscriber($config, $mockRedisSubscriber); @@ -126,6 +132,9 @@ public function testPsubscribe() ->twice() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = true; $subscriber = new Subscriber($config, $mockRedisSubscriber); @@ -164,6 +173,9 @@ public function testPsubscribeThrowsExceptionWhenConnectionClosedAbnormally() ->once() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = false; $subscriber = new Subscriber($config, $mockRedisSubscriber);