python-dependency-injector/examples/miniapps/fastapi-redis/fastapiredis/redis.py
Yan f0d9eda566
Update aioredis to 2.0.1 (#613)
* Update aioredis to 2.0.1

* Rearranged aioredis.from_url parameters
2022-12-18 21:27:36 -05:00

11 lines
322 B
Python

from typing import AsyncIterator
from aioredis import from_url, Redis
async def init_redis_pool(host: str, password: str) -> AsyncIterator[Redis]:
session = from_url(f"redis://{host}", password=password, encoding="utf-8", decode_responses=True)
yield session
session.close()
await session.wait_closed()