Commit b4864ef9 authored by Ivan Tyagov's avatar Ivan Tyagov

Do not explicitly mark a cache hit or miss.

Because this information is not yet used for cache management this is unnecessary
and introduces uneeded function call. 
Leave though commented methods for future reference / usage.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23688 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9a751365
...@@ -93,7 +93,7 @@ class DistributedRamCache(BaseCache): ...@@ -93,7 +93,7 @@ class DistributedRamCache(BaseCache):
cache_storage = self.getCacheStorage() cache_storage = self.getCacheStorage()
cache_id = self.checkAndFixCacheId(cache_id, scope) cache_id = self.checkAndFixCacheId(cache_id, scope)
cache_entry = cache_storage.get(cache_id) cache_entry = cache_storage.get(cache_id)
self.markCacheHit() #self.markCacheHit()
return cache_entry 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):
...@@ -105,7 +105,7 @@ class DistributedRamCache(BaseCache): ...@@ -105,7 +105,7 @@ class DistributedRamCache(BaseCache):
cache_duration = 360000 cache_duration = 360000
cache_entry = CacheEntry(value, cache_duration, calculation_time) cache_entry = CacheEntry(value, cache_duration, calculation_time)
cache_storage.set(cache_id, cache_entry, cache_duration) cache_storage.set(cache_id, cache_entry, cache_duration)
self.markCacheMiss() #self.markCacheMiss()
def expireOldCacheEntries(self, forceCheck = False): def expireOldCacheEntries(self, forceCheck = False):
""" Memcache has its own built in expire policy """ """ Memcache has its own built in expire policy """
......
...@@ -69,8 +69,10 @@ class RamCache(BaseCache): ...@@ -69,8 +69,10 @@ class RamCache(BaseCache):
cache = self.getCacheStorage() cache = self.getCacheStorage()
try: try:
cache_entry = cache[(scope, cache_id)] cache_entry = cache[(scope, cache_id)]
cache_entry.markCacheHit() # Note: tracking down cache hit could be achieved by uncommenting
self.markCacheHit() # methods below. In production environment this is likely uneeded
#cache_entry.markCacheHit()
#self.markCacheHit()
return cache_entry return cache_entry
except KeyError: except KeyError:
pass pass
...@@ -79,7 +81,7 @@ class RamCache(BaseCache): ...@@ -79,7 +81,7 @@ class RamCache(BaseCache):
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()
cache[(scope, cache_id)] = CacheEntry(value, cache_duration, calculation_time) cache[(scope, cache_id)] = CacheEntry(value, cache_duration, calculation_time)
self.markCacheMiss() #self.markCacheMiss()
def expireOldCacheEntries(self, forceCheck = False): def expireOldCacheEntries(self, forceCheck = False):
now = time.time() now = time.time()
......
...@@ -175,7 +175,7 @@ class SQLCache(BaseCache): ...@@ -175,7 +175,7 @@ class SQLCache(BaseCache):
## we found results ## we found results
result = result[0] result = result[0]
decoded_result = pickle.loads(base64.decodestring(result[0])) decoded_result = pickle.loads(base64.decodestring(result[0]))
self.markCacheHit() #self.markCacheHit()
cache_entry = CacheEntry(decoded_result, result[1], result[2]) cache_entry = CacheEntry(decoded_result, result[1], result[2])
return cache_entry return cache_entry
else: else:
...@@ -197,7 +197,7 @@ class SQLCache(BaseCache): ...@@ -197,7 +197,7 @@ class SQLCache(BaseCache):
stored_at = int(time.time()) stored_at = int(time.time())
sql_query = self.insert_key_sql %(self._db_cache_table_name, cache_id, value, scope, stored_at, cache_duration, calculation_time) sql_query = self.insert_key_sql %(self._db_cache_table_name, cache_id, value, scope, stored_at, cache_duration, calculation_time)
self.execSQLQuery(sql_query) self.execSQLQuery(sql_query)
self.markCacheMiss() #self.markCacheMiss()
def expireOldCacheEntries(self, forceCheck = False): def expireOldCacheEntries(self, forceCheck = False):
now = time.time() now = time.time()
......
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