From 8844131a0b87b61153a734d9fefa8e5e951e3ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 7 Sep 2021 14:45:10 +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 --- core/Cache/Base/Redis.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/Cache/Base/Redis.php b/core/Cache/Base/Redis.php index 4a816b9c..1494aa9f 100644 --- a/core/Cache/Base/Redis.php +++ b/core/Cache/Base/Redis.php @@ -67,16 +67,16 @@ class Redis implements StopHeartbeatCheck */ public function heartbeat_check(): void { - if (env('state','start') == 'exit') { + if (env('state', 'start') == 'exit') { return; } if ($this->_timer === -1 && Context::inCoroutine()) { $this->_timer = Timer::tick(1000, function () { try { - if (env('state','start') == 'exit') { - Kiri::getDi()->get(Logger::class)->critical('timer end'); - $this->stopHeartbeatCheck(); - } + if (env('state', 'start') == 'exit') { + Kiri::getDi()->get(Logger::class)->critical('timer end'); + $this->stopHeartbeatCheck(); + } if (time() - $this->_last > 10 * 60) { $this->stopHeartbeatCheck(); $this->pdo = null; @@ -150,7 +150,9 @@ class Redis implements StopHeartbeatCheck $this->read_timeout = 0; } $redis->select($this->database); - $redis->setOption(\Redis::OPT_READ_TIMEOUT, $this->read_timeout); + if ($this->read_timeout > 0) { + $redis->setOption(\Redis::OPT_READ_TIMEOUT, $this->read_timeout); + } $redis->setOption(\Redis::OPT_PREFIX, $this->prefix); return $redis;