From 660a4424c885aa924fc132b25cbff7619a87a4e3 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Thu, 4 Jun 2009 15:06:31 +0000
Subject: [PATCH] 0s of duration means that cache will never expire

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

diff --git a/product/ERP5Type/CachePlugins/BaseCache.py b/product/ERP5Type/CachePlugins/BaseCache.py
index 67d23d5745..d1f6ef3e3a 100644
--- a/product/ERP5Type/CachePlugins/BaseCache.py
+++ b/product/ERP5Type/CachePlugins/BaseCache.py
@@ -49,15 +49,18 @@ class CacheEntry(object):
   def __init__(self, value, cache_duration=None, calculation_time=0):
     self.value = value
     if cache_duration in (None, 0):
-      self.expires_at = None
+      self.expires_at = cache_duration
     else:
       self.expires_at = time.time() + cache_duration
     self._cache_hit_count = 0
     self.calculation_time = calculation_time
 
   def isExpired(self):
-    """ check cache entry for expiration """
-    return self.expires_at < time.time() or self.expires_at is None
+    """check cache entry for expiration
+      - None means allways expire
+      - 0 means never expire
+    """
+    return self.expires_at is None or self.expires_at != 0 and self.expires_at < time.time()
 
   def markCacheHit(self, delta=1):
     """ mark a read to this cache entry """
-- 
2.30.9