"""Client Redis asincrono (redis-py asyncio). Singleton semplice.""" from __future__ import annotations from typing import Optional import redis.asyncio as redis from core.config import settings _client: Optional[redis.Redis] = None def client() -> redis.Redis: global _client if _client is None: _client = redis.Redis( host=settings.redis_host, port=settings.redis_port, decode_responses=True, health_check_interval=30, ) return _client async def close() -> None: global _client if _client is not None: await _client.aclose() _client = None