From 1e89fa3c0e56afb5496bef15401a64451d2a8b6f Mon Sep 17 00:00:00 2001 From: chengxl Date: Thu, 7 Aug 2025 13:48:53 +0800 Subject: [PATCH] =?UTF-8?q?redis=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/QueueRedis.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/common/QueueRedis.php b/application/common/QueueRedis.php index 1aaacbf..f8a77d1 100644 --- a/application/common/QueueRedis.php +++ b/application/common/QueueRedis.php @@ -161,6 +161,14 @@ LUA; { try { $redis = $this->connect(); + //判断是否执行 + $sStatus = $redis->hGet($key, 'status'); + if (!empty($sStatus) && $sStatus == 'completed') { + return 2; + } + if (!empty($sStatus) && $sStatus == 'processing') { + return 3; + } $redis->hMSet($key, [ 'status' => 'processing', 'total' => $totalQuestions, @@ -168,9 +176,9 @@ LUA; 'start_time' => time() ]); $redis->expire($key, 10800); // 6小时过期 - return true; + return 1; } catch (\Exception $e) { - return false; + return 4; } } // 多问题按条件拆分成两个队列新增日志记录