Project started 🍾

This commit is contained in:
2026-06-01 18:47:59 +03:00
commit 4bca90a50e
39 changed files with 2340 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
"""Redis adapter: shared connection pool for cache and arq broker."""
from app.infrastructure.cache.redis import close_redis, get_redis
__all__ = ["close_redis", "get_redis"]
+26
View File
@@ -0,0 +1,26 @@
"""Redis client provider — a single shared async connection pool."""
from redis.asyncio import Redis
from app.core.config import get_settings
_client: Redis | None = None
def get_redis() -> Redis:
"""Return the process-wide Redis client (created on first use)."""
global _client
if _client is None:
_client = Redis.from_url(
str(get_settings().redis_url),
encoding="utf-8",
decode_responses=True,
)
return _client
async def close_redis() -> None:
global _client
if _client is not None:
await _client.aclose()
_client = None