feat(redis): add fuzzy key search toggle
This commit is contained in:
1 parent
3c93554630
commit
6546cccd1e
7 files changed
+69
-2
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user