From ea5b4736385b63fe18be4ee253e762052352f084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Mon, 18 Oct 2021 11:35:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-engine/Cache/Redis.php | 3 ++- kiri-engine/Environmental.php | 2 +- kiri-engine/Pool/Pool.php | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kiri-engine/Cache/Redis.php b/kiri-engine/Cache/Redis.php index 2a7ab20b..8a658bf3 100644 --- a/kiri-engine/Cache/Redis.php +++ b/kiri-engine/Cache/Redis.php @@ -11,6 +11,7 @@ namespace Kiri\Cache; use Annotation\Inject; use Exception; +use Server\Events\OnAfterRequest; use Server\Events\OnWorkerExit; use Server\Events\OnWorkerStop; use Kiri\Abstracts\Component; @@ -48,6 +49,7 @@ class Redis extends Component $length = Config::get('connections.pool.max', 10); + $this->eventProvider->on(OnAfterRequest::class, [$this, 'release'], 0); $this->eventProvider->on(OnWorkerExit::class, [$this, 'destroy'], 0); $connections->initConnections('Redis:' . $config['host'], true, $length); @@ -67,7 +69,6 @@ class Redis extends Component $data = $this->{$name}(...$arguments); } else { $data = $this->proxy()->{$name}(...$arguments); - $this->release(); } if (microtime(true) - $time >= 0.02) { $this->warning('Redis:' . Json::encode([$name, $arguments]) . (microtime(true) - $time)); diff --git a/kiri-engine/Environmental.php b/kiri-engine/Environmental.php index f8b431bf..f16c3e3d 100644 --- a/kiri-engine/Environmental.php +++ b/kiri-engine/Environmental.php @@ -18,7 +18,7 @@ class Environmental /** * @return bool */ - #[Pure] public function isMac(): bool + public function isMac(): bool { $output = strtolower(PHP_OS | PHP_OS_FAMILY); if (str_contains('mac', $output)) { diff --git a/kiri-engine/Pool/Pool.php b/kiri-engine/Pool/Pool.php index 5440ff4a..cb5a7317 100644 --- a/kiri-engine/Pool/Pool.php +++ b/kiri-engine/Pool/Pool.php @@ -132,6 +132,7 @@ class Pool extends Component * @param $channel * @return mixed * @throws ConfigException + * @throws Exception */ private function maxIdleQuantity($channel): mixed {