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):
cache_storage = self.getCacheStorage()
cache_id = self._getCacheId(cache_id, scope)
cache_entry = cache_storage.get(cache_id)
#Simulate the behaviour of a standard Dictionary
if not isinstance(cache_entry, CacheEntry):
if default is _MARKER:
#Error to connect memcached server
raise KeyError('Failed to retrieve value or to access memcached server: %s' % self._servers)
if isinstance(cache_entry, CacheEntry):
# since some memcached-like products does not support expiration, we
# check it by ourselves.
if not cache_entry.isExpired():
self.markCacheHit()
return cache_entry
else:
return default
# since some memcached-like products does not support expiration, we
# check it by ourselves.
if cache_entry.isExpired():
del cache_storage[cache_id]
return default
self.markCacheHit()
return cache_entry
del cache_storage[cache_id]
if default is _MARKER:
# Error to connect memcached server or cache is expired
raise KeyError('Failed to retrieve value or to access memcached server: %s or cache is expired.' % self._servers)
return default
def set(self, cache_id, scope, value, cache_duration=None, calculation_time=0):
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