From 983722d22f77573e58b00e676c451eaf65f081b6 Mon Sep 17 00:00:00 2001 From: as2252258 Date: Sun, 10 Jul 2022 00:15:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-engine/Redis/Helper.php | 49 ------------------------------------ kiri-engine/Redis/Redis.php | 3 +-- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/kiri-engine/Redis/Helper.php b/kiri-engine/Redis/Helper.php index 0d90f7c9..0a663257 100644 --- a/kiri-engine/Redis/Helper.php +++ b/kiri-engine/Redis/Helper.php @@ -39,9 +39,6 @@ class Helper implements StopHeartbeatCheck private int $_timer = -1; - private int $_last = 0; - - /** * @param array $config @@ -59,53 +56,11 @@ class Helper implements StopHeartbeatCheck } - public function init() - { - $this->heartbeat_check(); - } - - - /** - * - */ - public function heartbeat_check(): void - { - - if ($this->_timer === -1) { - $this->_timer = Timer::tick(1000, fn() => $this->waite()); - } - } - - - /** - * @throws Exception - */ - private function waite(): void - { - try { - if ($this->_timer === -1) { - Kiri::getDi()->get(Logger::class)->critical('timer end'); - $this->stopHeartbeatCheck(); - } - if (time() - $this->_last > intval($this->pool['tick'] ?? 60)) { - $this->stopHeartbeatCheck(); - - $this->pdo = null; - } - } catch (\Throwable $throwable) { - error($throwable); - } - } - - /** * clear client heartbeat */ public function stopHeartbeatCheck(): void { - if ($this->_timer > -1) { - Timer::clear($this->_timer); - } $this->_timer = -1; } @@ -132,10 +87,6 @@ class Helper implements StopHeartbeatCheck */ public function _pdo(): \Redis { - if ($this->_timer === -1) { - $this->heartbeat_check(); - } - $this->_last = time(); if (!($this->pdo instanceof \Redis) || !$this->pdo->ping('isOk')) { $this->pdo = $this->newClient(); } diff --git a/kiri-engine/Redis/Redis.php b/kiri-engine/Redis/Redis.php index 9ea05c0a..bd39f56c 100644 --- a/kiri-engine/Redis/Redis.php +++ b/kiri-engine/Redis/Redis.php @@ -58,7 +58,7 @@ class Redis extends Component * @throws ConfigException * @throws Exception */ - public function init() + public function init(): void { $config = $this->get_config(); @@ -78,7 +78,6 @@ class Redis extends Component */ public function __call($name, $arguments): mixed { - $time = microtime(true); if (method_exists($this, $name)) { $data = $this->{$name}(...$arguments); } else {