mirror of
https://github.com/FutureOfMedTech-FITM-hack/backend.git
synced 2024-11-22 06:26:34 +03:00
25 lines
566 B
Python
25 lines
566 B
Python
from fastapi import FastAPI
|
|
from redis.asyncio import ConnectionPool
|
|
|
|
from med_backend.settings import settings
|
|
|
|
|
|
def init_redis(app: FastAPI) -> None: # pragma: no cover
|
|
"""
|
|
Creates connection pool for redis.
|
|
|
|
:param app: current fastapi application.
|
|
"""
|
|
app.state.redis_pool = ConnectionPool.from_url(
|
|
str(settings.redis_url),
|
|
)
|
|
|
|
|
|
async def shutdown_redis(app: FastAPI) -> None: # pragma: no cover
|
|
"""
|
|
Closes redis connection pool.
|
|
|
|
:param app: current FastAPI app.
|
|
"""
|
|
await app.state.redis_pool.disconnect()
|