python-dependency-injector/examples/miniapps/fastapi-redis/fastapiredis/redis.py

13 lines
321 B
Python
Raw Normal View History

2021-01-04 06:15:27 +03:00
"""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()