From 7def223fc5755939b691718f2941d016f6581e0b Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Wed, 7 Oct 2009 15:41:05 +0000
Subject: [PATCH] Check that CacheEntry is not expired in has_key. If so,
 delete cached value and return False.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29455 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/CachePlugins/RamCache.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Type/CachePlugins/RamCache.py b/product/ERP5Type/CachePlugins/RamCache.py
index b590c57860..43b59d6199 100644
--- a/product/ERP5Type/CachePlugins/RamCache.py
+++ b/product/ERP5Type/CachePlugins/RamCache.py
@@ -109,7 +109,15 @@ class RamCache(BaseCache):
 
   def has_key(self, cache_id, scope):
     cache = self.getCacheStorage()
-    return cache.has_key((scope, cache_id))
+    cache_entry = cache.get((scope, cache_id))
+    to_return = False
+    if isinstance(cache_entry, CacheEntry):
+      if cache_entry.isExpired():
+        #Delete expired CacheEntry
+        self.delete(cache_id, scope)
+      else:
+        to_return = True
+    return to_return
 
   def getScopeList(self):
     scope_set = set()
-- 
2.30.9