summaryrefslogtreecommitdiff
path: root/cache.py
diff options
context:
space:
mode:
authorFabrice Douchant <Fabrice.Douchant@logilab.fr>2008-10-16 18:09:08 +0200
committerFabrice Douchant <Fabrice.Douchant@logilab.fr>2008-10-16 18:09:08 +0200
commit26297c83f2232d7e97f8114a97e8188ee3b943ab (patch)
tree1f14731d1c7bed0e8bbb32aa3ba0aa20a1db7b44 /cache.py
parent5293c540df765031ef8747e675c317106aba0c32 (diff)
downloadlogilab-common-26297c83f2232d7e97f8114a97e8188ee3b943ab.tar.gz
debug Cache on __getattr__ : raise KeyError before modifying underlying list
new Cache unittest to test it
Diffstat (limited to 'cache.py')
-rw-r--r--cache.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/cache.py b/cache.py
index 90da569..05373a6 100644
--- a/cache.py
+++ b/cache.py
@@ -55,8 +55,9 @@ class Cache(dict):
pass # key is already the most recently used key
def __getitem__(self, key):
+ value = super(Cache, self).__getitem__(key)
self._update_usage(key)
- return super(Cache, self).__getitem__(key)
+ return value
__getitem__ = locked(_acquire, _release)(__getitem__)
def __setitem__(self, key, item):
@@ -79,7 +80,18 @@ class Cache(dict):
def pop(self, key, default=_marker):
if super(Cache, self).has_key(key):
self._usage.remove(key)
- if default is _marker:
- return super(Cache, self).pop(key)
+ #if default is _marker:
+ # return super(Cache, self).pop(key)
return super(Cache, self).pop(key, default)
pop = locked(_acquire, _release)(pop)
+
+ def popitem(self):
+ raise NotImplementedError()
+
+ def setdefault(self, key, default=None):
+ raise NotImplementedError()
+
+ def update(self, other):
+ raise NotImplementedError()
+
+