Commit 1e398ccf authored by Nicolas Delaby's avatar Nicolas Delaby

* Fix mistake in default_value handling:

raise KeyError if value is not found for given key and no default value provided.
If default value is provided and value not found for given key, return default_value.
 * Call markCacheHit only if value is retrieved from cache container.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28050 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e3acf318
......@@ -49,6 +49,7 @@ def calcPythonObjectMemorySize(i):
s += calcPythonObjectMemorySize(v)
return s
_MARKER = []
class RamCache(BaseCache):
""" RAM based cache plugin."""
......@@ -70,9 +71,13 @@ class RamCache(BaseCache):
def getCacheStorage(self, **kw):
return self._cache_dict
def get(self, cache_id, scope, default=None):
def get(self, cache_id, scope, default=_MARKER):
cache = self.getCacheStorage()
cache_entry = cache.get((scope, cache_id), default)
if cache_entry is _MARKER:
raise KeyError, 'CacheEntry for key %s not Found' % ((scope, cache_id),)
if isinstance(cache_entry, CacheEntry):
#The value is well retrieved from cache storage
cache_entry.markCacheHit()
self.markCacheHit()
return cache_entry
......
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