Skip to content

Commit 246e364

Browse files
committed
fix: simplify store
1 parent b538778 commit 246e364

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/vsc/utils/cache.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ def update(self, key, data, threshold=None):
8383
@param data: whatever needs to be stored
8484
@param threshold: time in seconds
8585
"""
86-
old_timestamp, old_data = self.get(key, default=(None, None))
86+
#old_timestamp, old_data = self.get(key, default=(None, None))
8787
now = time.time()
88+
stored = self.set(key=key, value=(now, data), expire=threshold)
8889

89-
if not old_data or now - old_timestamp > threshold:
90-
self.set(key=key, value=(now, data), expire=threshold)
90+
if stored:
9191
return (now, data)
9292
else:
93-
return (old_timestamp, old_data)
93+
return (None, None)
9494

9595
def load(self, key):
9696
"""Load the stored data for the given key along with the timestamp it was stored.

0 commit comments

Comments
 (0)