Commit fa6fdeca authored by Nicolas Delaby's avatar Nicolas Delaby

typo

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26995 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 45d121cd
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -43,7 +44,7 @@ class CacheEntry(object): ...@@ -43,7 +44,7 @@ class CacheEntry(object):
calculation_time calculation_time
TODO: Based on above data we can have a different invalidation policy TODO: Based on above data we can have a different invalidation policy
""" """
def __init__(self, value, cache_duration=None, calculation_time=0): def __init__(self, value, cache_duration=None, calculation_time=0):
self.value = value self.value = value
if cache_duration in (None, 0): if cache_duration in (None, 0):
...@@ -56,11 +57,11 @@ class CacheEntry(object): ...@@ -56,11 +57,11 @@ class CacheEntry(object):
def isExpired(self): def isExpired(self):
""" check cache entry for expiration """ """ check cache entry for expiration """
return self.expires_at < time.time() or self.expires_at is None return self.expires_at < time.time() or self.expires_at is None
def markCacheHit(self, delta=1): def markCacheHit(self, delta=1):
""" mark a read to this cache entry """ """ mark a read to this cache entry """
self.cache_hits = self.cache_hits + delta self.cache_hits = self.cache_hits + delta
def getValue(self): def getValue(self):
""" return cached value """ """ return cached value """
return getattr(self, 'value', None) return getattr(self, 'value', None)
...@@ -68,16 +69,15 @@ class CacheEntry(object): ...@@ -68,16 +69,15 @@ class CacheEntry(object):
class BaseCache(object): class BaseCache(object):
""" Base Cache class """ """ Base Cache class """
## Time interval (s) to check for expired objects ## Time interval (s) to check for expired objects
cache_expire_check_interval = 60 cache_expire_check_interval = 60
def __init__(self, params={}): def __init__(self, params={}):
self._next_cache_expire_check_at = time.time() self._next_cache_expire_check_at = time.time()
self._cache_hits = 0 self._cache_hits = 0
self._cache_misses = 0 self._cache_misses = 0
def markCacheHit(self, delta=1): def markCacheHit(self, delta=1):
""" Mark a read operation from cache """ """ Mark a read operation from cache """
self._cache_hits = self._cache_hits + delta self._cache_hits = self._cache_hits + delta
...@@ -93,7 +93,7 @@ class BaseCache(object): ...@@ -93,7 +93,7 @@ class BaseCache(object):
def getCacheMisses(self): def getCacheMisses(self):
""" get cache missess """ """ get cache missess """
return self._cache_misses return self._cache_misses
def clearCache(self): def clearCache(self):
""" Clear cache """ """ Clear cache """
self._cache_hits = 0 self._cache_hits = 0
......
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