fix: Redis KEYS命令自动补通配符(*)
输入 KEYS match 自动变为 match* 模糊匹配, 无需手动加 *,同时匹配 ? [] 等 Redis 原生通配符
This commit is contained in:
1 parent
3b3cc32d45
commit
b8df2c0027
1 file changed
+6
-3
@@ -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
|
||||
|
||||
Reference in new issue
Block a user