You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromexpiringdictimportExpiringDictimporttimecache=ExpiringDict(max_len=10, max_age_seconds=10, refresh_on_access=True)
cache["foo"] ="bar"time.sleep(7)
print(cache["foo"]) #Value is accessed, timer is reset for this valuetime.sleep(7)
print(cache["foo"]) #Value is still there
Alternatively, a function to reset the timer
fromexpiringdictimportExpiringDict, ResetTimerimporttimecache=ExpiringDict(max_len=10, max_age_seconds=10)
cache["foo"] ="bar"time.sleep(7)
ResetTimer(cache, "foo") #Timer is reset for this valuetime.sleep(7)
print(cache["foo"]) #Value is still there
The text was updated successfully, but these errors were encountered:
For exemple:
Alternatively, a function to reset the timer
The text was updated successfully, but these errors were encountered: