Skip to content

Commit

Permalink
Cleaned up key expiry check
Browse files Browse the repository at this point in the history
  • Loading branch information
circulon committed Jul 25, 2024
1 parent 956753b commit 0d4709d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/masonite/cache/drivers/RedisDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def get(self, key: str, default: Any = None, **options) -> Any:
if not self.has(key):
return default or None

key_expires = self._internal_cache[key].get("expires", None)
if key_expires is None:
key_expiry = self._internal_cache[key].get("expires", None)
if key_expiry is None:
# the ttl value can also provide info on the
# existence of the key in the store
ttl = self.get_connection().ttl(key)
Expand All @@ -99,9 +99,9 @@ def get(self, key: str, default: Any = None, **options) -> Any:
self._internal_cache.pop(key)
return default or None

self._internal_cache[key]["expires"] = self._expires_from_ttl(ttl)
key_expiry = self._expires_from_ttl(ttl)
self._internal_cache[key]["expires"] = key_expiry

key_expiry = self._internal_cache[key].get("expires")
if pdlm.now() > key_expiry:
# the key has expired so remove it from the cache
self._internal_cache.pop(key)
Expand Down

0 comments on commit 0d4709d

Please sign in to comment.