From f0d9eda56689862c702ba7db13bb841d1e452cfa Mon Sep 17 00:00:00 2001 From: Yan <54033129+smirnovskoe@users.noreply.github.com> Date: Mon, 19 Dec 2022 05:27:36 +0300 Subject: [PATCH] Update aioredis to 2.0.1 (#613) * Update aioredis to 2.0.1 * Rearranged aioredis.from_url parameters --- .../miniapps/fastapi-redis/fastapiredis/redis.py | 12 +++++------- .../miniapps/fastapi-redis/fastapiredis/services.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/miniapps/fastapi-redis/fastapiredis/redis.py b/examples/miniapps/fastapi-redis/fastapiredis/redis.py index 3c5f17f9..e770906c 100644 --- a/examples/miniapps/fastapi-redis/fastapiredis/redis.py +++ b/examples/miniapps/fastapi-redis/fastapiredis/redis.py @@ -1,12 +1,10 @@ -"""Redis client module.""" - 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]: - pool = await create_redis_pool(f"redis://{host}", password=password) - yield pool - pool.close() - await pool.wait_closed() + session = from_url(f"redis://{host}", password=password, encoding="utf-8", decode_responses=True) + yield session + session.close() + await session.wait_closed() diff --git a/examples/miniapps/fastapi-redis/fastapiredis/services.py b/examples/miniapps/fastapi-redis/fastapiredis/services.py index 9a202c74..0cae0731 100644 --- a/examples/miniapps/fastapi-redis/fastapiredis/services.py +++ b/examples/miniapps/fastapi-redis/fastapiredis/services.py @@ -9,4 +9,4 @@ class Service: async def process(self) -> str: await self._redis.set("my-key", "value") - return await self._redis.get("my-key", encoding="utf-8") + return await self._redis.get("my-key")