Commit 395f9101 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

raise KeyError if cache is expired.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29664 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7e2f8bfe
...@@ -92,20 +92,18 @@ class DistributedRamCache(BaseCache): ...@@ -92,20 +92,18 @@ class DistributedRamCache(BaseCache):
cache_storage = self.getCacheStorage() cache_storage = self.getCacheStorage()
cache_id = self._getCacheId(cache_id, scope) cache_id = self._getCacheId(cache_id, scope)
cache_entry = cache_storage.get(cache_id) cache_entry = cache_storage.get(cache_id)
#Simulate the behaviour of a standard Dictionary if isinstance(cache_entry, CacheEntry):
if not isinstance(cache_entry, CacheEntry): # since some memcached-like products does not support expiration, we
if default is _MARKER: # check it by ourselves.
#Error to connect memcached server if not cache_entry.isExpired():
raise KeyError('Failed to retrieve value or to access memcached server: %s' % self._servers) self.markCacheHit()
return cache_entry
else: else:
return default del cache_storage[cache_id]
# since some memcached-like products does not support expiration, we if default is _MARKER:
# check it by ourselves. # Error to connect memcached server or cache is expired
if cache_entry.isExpired(): raise KeyError('Failed to retrieve value or to access memcached server: %s or cache is expired.' % self._servers)
del cache_storage[cache_id] return default
return default
self.markCacheHit()
return cache_entry
def set(self, cache_id, scope, value, cache_duration=None, calculation_time=0): def set(self, cache_id, scope, value, cache_duration=None, calculation_time=0):
cache_storage = self.getCacheStorage() cache_storage = self.getCacheStorage()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment