Commit 2b7b8dbb authored by Yoshinori Okuji's avatar Yoshinori Okuji

A little simplification.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18349 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 31dee15f
...@@ -68,20 +68,19 @@ class RamCache(BaseCache): ...@@ -68,20 +68,19 @@ class RamCache(BaseCache):
def get(self, cache_id, scope, default=None): def get(self, cache_id, scope, default=None):
cache = self.getCacheStorage() cache = self.getCacheStorage()
if self.has_key(cache_id, scope): try:
cache_entry = cache[scope].get(cache_id, default) cache_entry = cache[scope][cache_id]
cache_entry.markCacheHit() cache_entry.markCacheHit()
self.markCacheHit() self.markCacheHit()
return cache_entry return cache_entry
else: except KeyError:
pass
return default return default
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 = self.getCacheStorage() cache = self.getCacheStorage()
if not cache.has_key(scope): slot = cache.setdefault(scope, {})
## cache scope not initialized slot[cache_id] = CacheEntry(value, cache_duration, calculation_time)
cache[scope] = {}
cache[scope][cache_id] = CacheEntry(value, cache_duration, calculation_time)
self.markCacheMiss() self.markCacheMiss()
def expireOldCacheEntries(self, forceCheck = False): def expireOldCacheEntries(self, forceCheck = False):
...@@ -103,10 +102,8 @@ class RamCache(BaseCache): ...@@ -103,10 +102,8 @@ class RamCache(BaseCache):
def has_key(self, cache_id, scope): def has_key(self, cache_id, scope):
cache = self.getCacheStorage() cache = self.getCacheStorage()
if not cache.has_key(scope): slot = cache.setdefault(scope, {})
## cache scope not initialized return slot.has_key(cache_id)
cache[scope] = {}
return cache[scope].has_key(cache_id)
def getScopeList(self): def getScopeList(self):
scope_list = [] scope_list = []
......
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