python-dependency-injector/examples/miniapps/fastapi-redis/fastapiredis/redis.py
2021-01-03 22:20:27 -05:00

13 lines
321 B
Python

"""Redis client module."""
from typing import AsyncIterator
from aioredis import create_redis_pool, Redis
async def init_redis_pool(host: str, password: str) -> AsyncIterator[Redis]:
pool = await create_redis_pool(f'redis://{host}', password=password)
yield pool
pool.close()
await pool.wait_closed()