feat(B-RED): Zentraler Redis Pool — cache.py, monitoring.py, worker.py auf get_redis() umgestellt

B-RED: 5 direkte aioredis.from_url() Konstruktoren auf get_redis() umgestellt
- cache.py: get_cache() delegiert auf get_redis(), _cache_redis Singleton entfernt
- monitoring.py: check_redis() und check_worker() nutzen get_redis()
- worker.py: _acquire_cron_lock() und _release_cron_lock() nutzen get_redis()
- 0 verbleibende direkte aioredis.from_url() außerhalb auth.py

B-RED-TEST: 8 Tests in test_redis_pool.py — alle grün
- Singleton, get_cache delegation, SET/GET, parallel, reset, no-direct-from_url checks
This commit is contained in:
Agent Zero
2026-08-13 16:25:17 +02:00
parent e3ca3b3d28
commit e9164979b5
4 changed files with 125 additions and 41 deletions
+3 -8
View File
@@ -7,17 +7,12 @@ from typing import Any
import redis.asyncio as aioredis
from app.config import get_settings
_cache_redis: aioredis.Redis | None = None
from app.core.auth import get_redis
def get_cache() -> aioredis.Redis:
"""Get or create the cache Redis client."""
global _cache_redis
if _cache_redis is None:
_cache_redis = aioredis.from_url(get_settings().redis_url, decode_responses=True)
return _cache_redis
"""Get the cache Redis client (delegates to the global ``get_redis()`` singleton)."""
return get_redis()
async def cache_get(key: str) -> Any | None: