Skip to content

Instantly share code, notes, and snippets.

@vishvananda
Created March 7, 2012 21:55
Show Gist options
  • Select an option

  • Save vishvananda/1996485 to your computer and use it in GitHub Desktop.

Select an option

Save vishvananda/1996485 to your computer and use it in GitHub Desktop.
diff --git a/nova/testing/fake/memcache.py b/nova/testing/fake/memcache.py
index e4f238a..6677ed3 100644
--- a/nova/testing/fake/memcache.py
+++ b/nova/testing/fake/memcache.py
@@ -30,10 +30,11 @@ class Client(object):
def get(self, key):
"""Retrieves the value for a key or None."""
- (timeout, value) = self.cache.get(key, (0, None))
- if timeout == 0 or utils.utcnow_ts() < timeout:
- return value
- return None
+ for key in list(self.cache.iterkeys()):
+ (timeout, value) = self.cache.get(key, (0, None))
+ if timeout and utils.utcnow_ts >= timeout:
+ del self.cache[key]
+ return self.cache.get(key, (0, None))[1]
def set(self, key, value, time=0, min_compress_len=0):
"""Sets the value for a key."""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment