Skip to content

Commit b5de10c

Browse files
committed
fix: use pop instead of del to avoid potential KeyError issues
1 parent 1911241 commit b5de10c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

infisical_sdk/util/secrets_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get(self, cache_key: str) -> Any:
4141
if time.time() - timestamp <= self.ttl:
4242
return pickle.loads(serialized_value)
4343
else:
44-
del self.cache[cache_key]
44+
self.cache.pop(cache_key, None)
4545
return None
4646
else:
4747
return None
@@ -60,7 +60,7 @@ def unset(self, cache_key: str) -> None:
6060
return
6161

6262
with self.lock:
63-
del self.cache[cache_key]
63+
self.cache.pop(cache_key, None)
6464

6565

6666
def _cleanup_expired_items(self) -> None:
@@ -72,7 +72,7 @@ def _cleanup_expired_items(self) -> None:
7272
if current_time - timestamp > self.ttl
7373
]
7474
for key in expired_keys:
75-
del self.cache[key]
75+
self.cache.pop(key, None)
7676

7777
def _cleanup_worker(self) -> None:
7878
"""Background worker that periodically cleans up expired items."""

0 commit comments

Comments
 (0)