eksplicit mapping af envs
This commit is contained in:
16
backend/app/core/redis.py
Normal file
16
backend/app/core/redis.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import redis.asyncio as redis
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
_pool: redis.ConnectionPool | None = None
|
||||
|
||||
|
||||
def get_pool() -> redis.ConnectionPool:
|
||||
global _pool
|
||||
if _pool is None:
|
||||
_pool = redis.ConnectionPool.from_url(settings.redis_url, decode_responses=True)
|
||||
return _pool
|
||||
|
||||
|
||||
def get_client() -> redis.Redis:
|
||||
return redis.Redis(connection_pool=get_pool())
|
||||
Reference in New Issue
Block a user