starlette-session
starlette-session copied to clipboard
Backend Memcache Set -- argument set is set to None
Hey,
It seems there might be a little error in the configuration of the MemcacheSessionBackend
object.
When trying the code as displayed in the examples I get the following error:
raise MemcacheIllegalInputError(
pymemcache.exceptions.MemcacheIllegalInputError: expire must be integer, got bad value: None
After looking at the documentation for pymemcache, it seems that the exp
argument should be an Integer indeed (default at 0).
So I would recommend changing the MemcacheSessionBackend
from:
async def set(
self, key: str, value: dict, exp: Optional[int] = None, **kwargs: dict
) -> Optional[str]:
return self.memcache.set(key, value, expire=exp, **kwargs)
to:
async def set(
self, key: str, value: dict, exp: Optional[int] = None, **kwargs: dict
) -> Optional[str]:
if exp is None:
return self.memcache.set(key, value, expire=0, **kwargs)
else:
return self.memcache.set(key, value, expire=exp, **kwargs)