Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cashews/backends/redis/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async def is_locked(
return True

async def unlock(self, key: Key, value: Value) -> bool:
if "UNLOCK" not in self._sha:
if self._sha.get("UNLOCK") is None:
self._sha["UNLOCK"] = await self._client.script_load(_UNLOCK.replace("\n", " "))
return await self._client.evalsha(self._sha["UNLOCK"], 1, key, value)

Expand Down Expand Up @@ -237,7 +237,7 @@ async def _transform_value(self, key: Key, value: bytes | None, default: Value |
async def incr(self, key: Key, value: int = 1, expire: float | None = None) -> int:
if not expire:
return await self._client.incr(key, amount=value)
if "INCR_EXPIRE" not in self._sha:
if self._sha.get("INCR_EXPIRE") is None:
self._sha["INCR_EXPIRE"] = await self._client.script_load(_INCR_EXPIRE.replace("\n", " "))
expire = expire or 0
expire = int(expire * 1000)
Expand Down Expand Up @@ -282,7 +282,7 @@ async def slice_incr(
) -> int:
expire = expire or 0
expire = int(expire * 1000)
if "INCR_SLICE" not in self._sha:
if self._sha.get("INCR_SLICE") is None:
self._sha["INCR_SLICE"] = await self._client.script_load(_INCR_SLICE.replace("\n", " "))
return await self._client.evalsha(self._sha["INCR_SLICE"], 1, key, start, end, maxvalue, expire)

Expand Down
Loading