From b8df2c002744672c3430442ca4ad55a5403c256a Mon Sep 17 00:00:00 2001 From: logan Date: Thu, 28 May 2026 16:07:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Redis=20KEYS=E5=91=BD=E4=BB=A4=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=A1=A5=E9=80=9A=E9=85=8D=E7=AC=A6(*)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 输入 KEYS match 自动变为 match* 模糊匹配, 无需手动加 *,同时匹配 ? [] 等 Redis 原生通配符 --- backend/internal/handler/instance_detail.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/internal/handler/instance_detail.go b/backend/internal/handler/instance_detail.go index 0636f05..8941b97 100644 --- a/backend/internal/handler/instance_detail.go +++ b/backend/internal/handler/instance_detail.go @@ -717,13 +717,16 @@ func executeRedisQuery(instance *model.Instance, dbSelect string, command string args = append(args, p) } - // For KEYS command, use SCAN with COUNT instead for safety + pagination - if cmd == "KEYS" && strings.Contains(parts[len(parts)-1], "*") { - // Replace KEYS * with SCAN-based pagination + // For KEYS command, use SCAN with pagination (auto-append * if no wildcard) + if cmd == "KEYS" { pattern := "*" if len(parts) > 1 { pattern = parts[1] } + // Auto-append * if pattern has no wildcard + if !strings.Contains(pattern, "*") && !strings.Contains(pattern, "?") && !strings.Contains(pattern, "[") { + pattern = pattern + "*" + } var allKeys []string cursor := uint64(0) maxScan := offset + limit