tessl install tessl/pypi-aioredis@2.0.0asyncio (PEP 3156) Redis support
Agent Success
Agent success rate when using this tile
98%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.01x
Baseline
Agent success rate without this tile
97%
Build a Redis command monitoring tool that captures and analyzes commands executed on a Redis server in real-time.
Create a monitor that connects to a Redis server and captures executed commands.
Analyze captured commands to extract useful statistics and patterns.
Generate reports from monitored command data.
@generates
import asyncio
from typing import Dict, List, Any, AsyncIterator
class RedisMonitor:
"""Monitor and analyze Redis commands in real-time."""
def __init__(self, host: str = 'localhost', port: int = 6379):
"""
Initialize Redis monitor.
Args:
host: Redis server host
port: Redis server port
"""
pass
async def start_monitoring(self, duration: float) -> None:
"""
Start monitoring Redis commands for specified duration.
Args:
duration: How long to monitor in seconds
"""
pass
def get_command_counts(self) -> Dict[str, int]:
"""
Get count of each command type observed.
Returns:
Dictionary mapping command names to their counts
"""
pass
def get_top_commands(self, n: int = 5) -> List[tuple[str, int]]:
"""
Get the N most frequently used commands.
Args:
n: Number of top commands to return
Returns:
List of (command_name, count) tuples sorted by count descending
"""
pass
def generate_report(self) -> str:
"""
Generate a text report of monitoring results.
Returns:
Formatted string report with command statistics
"""
pass
async def close(self) -> None:
"""Close the monitor connection."""
passProvides async Redis client support with command monitoring capabilities.