mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-08-02 11:10:21 +03:00
Update aioredis to 2.0.1
This commit is contained in:
parent
6f859e4aa2
commit
680cfcc652
|
@ -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}", encoding="utf-8", password=password, decode_responses=True)
|
||||
yield session
|
||||
session.close()
|
||||
await session.wait_closed()
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user