better cache cleanup
This commit is contained in:
parent
045eb91be3
commit
563c2af2c3
1 changed files with 4 additions and 4 deletions
|
@ -7,12 +7,12 @@ class Cache(dict):
|
|||
self._added = {}
|
||||
|
||||
def get(self, key):
|
||||
if key in self._added:
|
||||
if self._added[key] < time.time():
|
||||
now = time.time()
|
||||
for key, value in self._added.items():
|
||||
if value < now:
|
||||
del self._added[key]
|
||||
del self[key]
|
||||
return
|
||||
return dict.__getitem__(self, key)
|
||||
return dict.get(self, key)
|
||||
|
||||
def set(self, key, value, ttl=None):
|
||||
ttl = ttl or self._ttl
|
||||
|
|
Loading…
Reference in a new issue