mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-21 17:16:46 +03:00
Update aioredis to 2.0.1 (#613)
* Update aioredis to 2.0.1 * Rearranged aioredis.from_url parameters
This commit is contained in:
parent
55f81bd754
commit
f0d9eda566
|
@ -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()
|
||||||
|
|
|
@ -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")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user