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 server health monitoring utility that checks server status and provides database statistics.
True if the server responds correctly, False otherwise @test@generates
import asyncio
from typing import Dict, Any, Optional
class RedisHealthMonitor:
"""
A Redis server health monitoring utility.
This class provides methods to check Redis server health status,
retrieve database statistics, and perform database management operations.
"""
def __init__(self, redis_url: str = "redis://localhost"):
"""
Initialize the health monitor with a Redis connection URL.
Args:
redis_url: Redis connection URL (default: "redis://localhost")
"""
pass
async def connect(self) -> None:
"""Establish connection to the Redis server."""
pass
async def disconnect(self) -> None:
"""Close the connection to the Redis server."""
pass
async def check_health(self) -> bool:
"""
Check if the Redis server is responsive.
Returns:
True if server responds to ping, False otherwise
"""
pass
async def echo_message(self, message: str) -> bool:
"""
Send a message to the server and verify the echo response.
Args:
message: The message to echo
Returns:
True if the echoed message matches the sent message, False otherwise
"""
pass
async def get_key_count(self) -> int:
"""
Get the number of keys in the current database.
Returns:
The count of keys in the current database
"""
pass
async def get_server_info(self) -> Dict[str, Any]:
"""
Retrieve comprehensive server information.
Returns:
Dictionary containing server information including sections like
'server', 'clients', 'memory', 'stats', etc.
"""
pass
async def flush_current_database(self) -> bool:
"""
Remove all keys from the current database.
Returns:
True if the operation succeeded
"""
passProvides asyncio Redis client functionality for server health checks, database inspection, and management operations.