feat(redis): add fuzzy key search toggle

This commit is contained in:
t8y2 committed 2026-06-03 01:53:24 +08:00
1 parent 3c93554630
commit 6546cccd1e
7 files changed
+69 -2

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
const REDIS_GLOB_SPECIAL_CHARS = /[\\*?[\]]/g;
export function escapeRedisGlobText(value: string): string {
return value.replace(REDIS_GLOB_SPECIAL_CHARS, "\\$&");
}
export function redisKeySearchPattern(value: string, fuzzy: boolean): string {
const pattern = value.trim();
if (!pattern) return "*";
return fuzzy ? `*${escapeRedisGlobText(pattern)}*` : pattern;
}