summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Hutchinson <jlhutch@gmail.com>2011-07-15 22:22:40 -0500
committerJay Hutchinson <jlhutch@gmail.com>2011-07-15 22:22:40 -0500
commitbca4139808bdfc0796beba55da84ff558e5538fc (patch)
treeee976961cc347fcbc441c6f9aa1dd8d62f58c123
parentecc361e79226ac98c260351f2f1976160b54c741 (diff)
downloadpylru-bca4139808bdfc0796beba55da84ff558e5538fc.tar.gz
Fixed two bugs in lruwrap class.
-rw-r--r--pylru.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pylru.py b/pylru.py
index 27df250..4760b4a 100644
--- a/pylru.py
+++ b/pylru.py
@@ -298,6 +298,11 @@ class lruwrap(object):
self.cache = lrucache(size, callback)
def __len__(self):
+ # XXX Need a way to efficiently return len() when writeback is turned
+ # on. If you really need the length you can call sync() then call
+ # len(self.store), but syncing all of the time kind of defeats the
+ # purpose of a writeback cache.
+ assert self.writeback == False
return len(self.store)
def size(self, size=None):
@@ -324,7 +329,9 @@ class lruwrap(object):
except KeyError:
pass
- return self.store[key] # XXX Re-raise exception?
+ value = self.store[key]
+ self.cache[key] = value
+ return value
def __setitem__(self, key, value):
self.cache[key] = value