Add get_stats to MemoryBackend and update pytest config
Added get_stats() method for consistency with RedisBackend. Also added httpx and pytest-asyncio as dev dependencies.
This commit is contained in:
@@ -134,6 +134,19 @@ class MemoryBackend(Backend):
|
||||
self._cleanup_task = None
|
||||
await self.clear()
|
||||
|
||||
async def ping(self) -> bool:
|
||||
"""Check if the backend is available. Always returns True for memory backend."""
|
||||
return True
|
||||
|
||||
async def get_stats(self) -> dict[str, Any]:
|
||||
"""Get statistics about the rate limit storage."""
|
||||
async with self._lock:
|
||||
return {
|
||||
"total_keys": len(self._data),
|
||||
"max_size": self._max_size,
|
||||
"backend": "memory",
|
||||
}
|
||||
|
||||
def __len__(self) -> int:
|
||||
"""Return the number of stored entries."""
|
||||
return len(self._data)
|
||||
|
||||
Reference in New Issue
Block a user