0

Added better error handling for corrupt chunks

This commit is contained in:
Andrew Brown
2012-03-17 22:41:11 -04:00
parent 9b7226e91e
commit e9cf747513
4 changed files with 71 additions and 10 deletions

View File

@@ -59,10 +59,10 @@ class LRUCache(object):
"""
self.cache = {}
self.listhead = LRUCache._LinkNode()
self.listtail = LRUCache._LinkNode()
# Two sentinel nodes at the ends of the linked list simplify boundary
# conditions in the code below.
self.listhead = LRUCache._LinkNode()
self.listtail = LRUCache._LinkNode()
self.listhead.right = self.listtail
self.listtail.left = self.listhead
@@ -125,6 +125,18 @@ class LRUCache(object):
cache[key] = link
def __delitem__(self, key):
# Used to flush the cache of this key
link = self.cache[key]
del cache[key]
link.left.right = link.right
link.right.left = link.left
# Call the destructor
d = self.destructor
if d:
d(link.value)
# memcached is an option, but unless your IO costs are really high, it just
# ends up adding overhead and isn't worth it.
try: