Skip to content

Commit 9ef8caa

Browse files
committed
Remove get_all_keys function to prevent production performance issues
- Removed get_all_keys function that uses blocking KEYS command - KEYS command can cause performance issues on large datasets - Users can still use scan_keys or scan_all_keys for safe key retrieval
1 parent d9b666e commit 9ef8caa

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

src/tools/misc.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,6 @@ async def rename(old_key: str, new_key: str) -> Dict[str, Any]:
9797
return {"error": str(e)}
9898

9999

100-
@mcp.tool()
101-
async def get_all_keys(pattern: str = "*") -> list:
102-
"""
103-
Retrieve all keys matching a pattern from the Redis database using the KEYS command.
104-
105-
Note: The KEYS command is blocking and can impact performance on large databases.
106-
For production use with large datasets, consider using SCAN instead.
107-
108-
Args:
109-
pattern: Pattern to match keys against (default is "*" for all keys).
110-
Common patterns: "user:*", "cache:*", "*:123", etc.
111-
112-
Returns:
113-
A list of keys matching the pattern or an error message.
114-
"""
115-
try:
116-
r = RedisConnectionManager.get_connection()
117-
keys = r.keys(pattern)
118-
# Convert bytes to strings if needed
119-
return [key.decode('utf-8') if isinstance(key, bytes) else key for key in keys]
120-
except RedisError as e:
121-
return f"Error retrieving keys with pattern '{pattern}': {str(e)}"
122-
123-
124100
@mcp.tool()
125101
async def scan_keys(pattern: str = "*", count: int = 100, cursor: int = 0) -> dict:
126102
"""

0 commit comments

Comments
 (0)