redis.py 292 B

12345678910
  1. from typing import AsyncIterator
  2. from aioredis import create_redis_pool, Redis
  3. async def init_redis_pool(host: str, password: str) -> AsyncIterator[Redis]:
  4. pool = await create_redis_pool(f"redis://{host}", password=password)
  5. yield pool
  6. pool.close()
  7. await pool.wait_closed()