Make quart-session compatible with aioredis 2.0

This commit is contained in:
Adrien YHUEL
2021-08-31 04:33:41 +02:00
parent ff41a72222
commit 264a9ad369
2 changed files with 9 additions and 5 deletions
+5 -4
View File
@@ -228,8 +228,9 @@ class RedisSessionInterface(SessionInterface):
"""
if self.backend is None:
import aioredis
self.backend = await aioredis.create_redis(
"redis://localhost")
self.backend = await aioredis.from_url(
"redis://localhost", encoding="utf-8", decode_responses=True
)
async def get(self, key: str, app: Quart = None):
return await self.backend.get(key)
@@ -239,8 +240,8 @@ class RedisSessionInterface(SessionInterface):
if app and not expiry:
expiry = total_seconds(app.permanent_session_lifetime)
return await self.backend.setex(
key=key, value=value,
seconds=expiry)
name=key, value=value,
time=expiry)
async def delete(self, key: str, app: Quart = None):
return await self.backend.delete(key)