From 5c929d3c32d1890070814a407b8584edf4c5d0b9 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Mon, 18 May 2009 08:48:34 +0000
Subject: [PATCH] rename attribute use for performance tracking

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27014 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/CachePlugins/BaseCache.py | 27 ++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/product/ERP5Type/CachePlugins/BaseCache.py b/product/ERP5Type/CachePlugins/BaseCache.py
index 09a3eae201..490de2ca92 100644
--- a/product/ERP5Type/CachePlugins/BaseCache.py
+++ b/product/ERP5Type/CachePlugins/BaseCache.py
@@ -51,7 +51,7 @@ class CacheEntry(object):
       self.expires_at = None
     else:
       self.expires_at = time.time() + cache_duration
-    self.cache_hits = 0
+    self._cache_hit_count = 0
     self.calculation_time = calculation_time
 
   def isExpired(self):
@@ -60,12 +60,13 @@ class CacheEntry(object):
 
   def markCacheHit(self, delta=1):
     """ mark a read to this cache entry """
-    self.cache_hits = self.cache_hits + delta 
+    self._cache_hit_count = self._cache_hit_count + delta 
 
   def getValue(self):
     """ return cached value """ 
     return getattr(self, 'value', None)
 
+ACTIVATE_TRACKING = False
 
 class BaseCache(object):
   """ Base Cache class """
@@ -75,26 +76,28 @@ class BaseCache(object):
 
   def __init__(self, params={}):
     self._next_cache_expire_check_at = time.time()
-    self._cache_hits = 0
-    self._cache_misses = 0
+    self._cache_hit_count = 0
+    self._cache_miss_count = 0
 
   def markCacheHit(self, delta=1):
     """ Mark a read operation from cache """
-    self._cache_hits = self._cache_hits + delta
+    if ACTIVATE_TRACKING:
+      self._cache_hit_count = self._cache_hit_count + delta
 
   def markCacheMiss(self, delta=1):
     """ Mark a write operation to cache """
-    self._cache_misses = self._cache_misses + delta
+    if ACTIVATE_TRACKING:
+      self._cache_miss_count = self._cache_miss_count + delta
 
-  def getCacheHits(self):
+  def getCacheHitCount(self):
     """ get cache hits """
-    return self._cache_hits
+    return self._cache_hit_count
 
-  def getCacheMisses(self):
+  def getCacheMissCount(self):
     """ get cache missess """
-    return self._cache_misses
+    return self._cache_miss_count
 
   def clearCache(self):
     """ Clear cache """
-    self._cache_hits = 0
-    self._cache_misses = 0
+    self._cache_hit_list = 0
+    self._cache_miss_count = 0
-- 
2.30.9