| 123456789101112131415 |
- from typing import Optional
- from redis.asyncio import Redis
- from app.core.config import settings
- _redis_client: Optional[Redis] = None
- async def get_redis_client() -> Redis:
- global _redis_client
- if _redis_client is None:
- _redis_client = Redis.from_url(
- settings.redis_url,
- decode_responses=True
- )
- return _redis_client
|