git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ce46442
)
remove expired data
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Sat, 29 Oct 2011 13:51:52 +0000
(09:51 -0400)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Sat, 29 Oct 2011 13:51:52 +0000
(09:51 -0400)
sfa/util/cache.py
patch
|
blob
|
history
diff --git
a/sfa/util/cache.py
b/sfa/util/cache.py
index
0383ccc
..
a2ded4a
100644
(file)
--- a/
sfa/util/cache.py
+++ b/
sfa/util/cache.py
@@
-82,9
+82,18
@@
class Cache:
def get(self, key):
data = self.cache.get(key)
- if not data or data.is_expired():
- return None
- return data.get_data()
+ if not data:
+ data = None
+ elif data.is_expired():
+ self.pop(key)
+ data = None
+ else:
+ data = data.get_data()
+ return data
+
+ def pop(self, key):
+ if key in self.cache:
+ self.cache.pop(key)
def dump(self):
result = {}