mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
Full mypy --strict type checking pass
This commit is contained in:
@@ -13,18 +13,18 @@ class RedisBackend(Backend):
|
||||
|
||||
async def get_with_ttl(self, key: str) -> Tuple[int, Optional[bytes]]:
|
||||
async with self.redis.pipeline(transaction=not self.is_cluster) as pipe:
|
||||
return await pipe.ttl(key).get(key).execute()
|
||||
return await pipe.ttl(key).get(key).execute() # type: ignore[union-attr,no-any-return]
|
||||
|
||||
async def get(self, key: str) -> Optional[bytes]:
|
||||
return await self.redis.get(key)
|
||||
return await self.redis.get(key) # type: ignore[union-attr]
|
||||
|
||||
async def set(self, key: str, value: bytes, expire: Optional[int] = None) -> None:
|
||||
return await self.redis.set(key, value, ex=expire)
|
||||
await self.redis.set(key, value, ex=expire) # type: ignore[union-attr]
|
||||
|
||||
async def clear(self, namespace: Optional[str] = None, key: Optional[str] = None) -> int:
|
||||
if namespace:
|
||||
lua = f"for i, name in ipairs(redis.call('KEYS', '{namespace}:*')) do redis.call('DEL', name); end"
|
||||
return await self.redis.eval(lua, numkeys=0)
|
||||
return await self.redis.eval(lua, numkeys=0) # type: ignore[union-attr,no-any-return]
|
||||
elif key:
|
||||
return await self.redis.delete(key)
|
||||
return await self.redis.delete(key) # type: ignore[union-attr]
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user