[Erp5-report] r29664 - /erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Oct 15 12:01:14 CEST 2009
Author: kazuhiko
Date: Thu Oct 15 12:01:11 2009
New Revision: 29664
URL: http://svn.erp5.org?rev=29664&view=rev
Log:
raise KeyError if cache is expired.
Modified:
erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
Modified: erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py?rev=29664&r1=29663&r2=29664&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] Thu Oct 15 12:01:11 2009
@@ -92,20 +92,18 @@
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()
More information about the Erp5-report
mailing list