Merge pull request #6 from adrienyhuel/master
Make quart-session compatible with aioredis 2.0
This commit is contained in:
@@ -228,8 +228,9 @@ class RedisSessionInterface(SessionInterface):
|
|||||||
"""
|
"""
|
||||||
if self.backend is None:
|
if self.backend is None:
|
||||||
import aioredis
|
import aioredis
|
||||||
self.backend = await aioredis.create_redis(
|
self.backend = await aioredis.from_url(
|
||||||
"redis://localhost")
|
"redis://localhost", encoding="utf-8", decode_responses=True
|
||||||
|
)
|
||||||
|
|
||||||
async def get(self, key: str, app: Quart = None):
|
async def get(self, key: str, app: Quart = None):
|
||||||
return await self.backend.get(key)
|
return await self.backend.get(key)
|
||||||
@@ -239,8 +240,8 @@ class RedisSessionInterface(SessionInterface):
|
|||||||
if app and not expiry:
|
if app and not expiry:
|
||||||
expiry = total_seconds(app.permanent_session_lifetime)
|
expiry = total_seconds(app.permanent_session_lifetime)
|
||||||
return await self.backend.setex(
|
return await self.backend.setex(
|
||||||
key=key, value=value,
|
name=key, value=value,
|
||||||
seconds=expiry)
|
time=expiry)
|
||||||
|
|
||||||
async def delete(self, key: str, app: Quart = None):
|
async def delete(self, key: str, app: Quart = None):
|
||||||
return await self.backend.delete(key)
|
return await self.backend.delete(key)
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ setup(
|
|||||||
platforms='any',
|
platforms='any',
|
||||||
install_requires=INSTALL_REQUIRES,
|
install_requires=INSTALL_REQUIRES,
|
||||||
tests_require=INSTALL_REQUIRES + ["asynctest", "hypothesis", "pytest", "pytest-asyncio"],
|
tests_require=INSTALL_REQUIRES + ["asynctest", "hypothesis", "pytest", "pytest-asyncio"],
|
||||||
extras_require={"dotenv": ["python-dotenv"]},
|
extras_require={
|
||||||
|
"dotenv": ["python-dotenv"],
|
||||||
|
"redis": ["aioredis>=2.0.0"]
|
||||||
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
|
|||||||
Reference in New Issue
Block a user