prepared skeleton for lab5
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from redis.asyncio import BlockingConnectionPool, Redis
|
||||
from redis.asyncio.retry import Retry
|
||||
from redis.backoff import NoBackoff
|
||||
|
||||
from app.core.config import Settings
|
||||
|
||||
def create_redis_client(settings: Settings) -> Redis:
|
||||
password = (
|
||||
settings.redis_password.get_secret_value() if settings.redis_password else None
|
||||
)
|
||||
pool = BlockingConnectionPool(
|
||||
host=settings.redis_host,
|
||||
port=settings.redis_port,
|
||||
db=settings.redis_db,
|
||||
password=password,
|
||||
max_connections=settings.redis_max_connections,
|
||||
timeout=settings.redis_pool_timeout_seconds,
|
||||
socket_connect_timeout=settings.redis_connect_timeout_seconds,
|
||||
socket_timeout=settings.redis_socket_timeout_seconds,
|
||||
retry=Retry(NoBackoff(), retries=1),
|
||||
decode_responses=True,
|
||||
)
|
||||
return Redis.from_pool(pool)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user