Skip to content

Lifetime

init_redis(app)

Creates connection pool for redis.

Parameters:

Name Type Description Default
app FastAPI

current fastapi application.

required
Source code in hestia/services/redis/lifetime.py
 7
 8
 9
10
11
12
13
14
15
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),
    )

shutdown_redis(app) async

Closes redis connection pool.

Parameters:

Name Type Description Default
app FastAPI

current FastAPI app.

required
Source code in hestia/services/redis/lifetime.py
18
19
20
21
22
23
24
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()