Update aioredis to 2.0.1 (#613)

* Update aioredis to 2.0.1

* Rearranged aioredis.from_url parameters
This commit is contained in:
Yan 2022-12-19 05:27:36 +03:00 committed by GitHub
parent 55f81bd754
commit f0d9eda566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

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

View File

@ -9,4 +9,4 @@ class Service:
async def process(self) -> str: async def process(self) -> str:
await self._redis.set("my-key", "value") await self._redis.set("my-key", "value")
return await self._redis.get("my-key", encoding="utf-8") return await self._redis.get("my-key")