Commit df3a36d6 authored by Nicolas Delaby's avatar Nicolas Delaby

* Fix delete method on caching Methods and test it.

* Not sure it is used


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32227 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fe3394ff
......@@ -207,13 +207,14 @@ class CachingMethod:
*args, **kwd)
return value
def delete(self, id=None, cache_factory=None, scope=DEFAULT_CACHE_SCOPE):
""" Delete cache key. """
if id is None:
id = self.id
if cache_factory is None:
def delete(self, *args, **kwd):
""" Delete cache key.
accept same arguments as __call__ to clear
the cache entry with the same cache_id
"""
cache_factory = self.cache_factory
cache_id = self.generateCacheId(id)
scope = kwd.pop('scope', DEFAULT_CACHE_SCOPE)
cache_id = self.generateCacheId(self.id, *args, **kwd)
cache_factory = CachingMethod.factories[cache_factory]
for cp in cache_factory.getCachePluginList():
cp.delete(cache_id, scope)
......
......@@ -261,6 +261,22 @@ return result
## Cache cleared shouldn't be previously cached
self.assert_(1.0 < calculation_time)
# Test delete method on CachingMethod
print "\n\tCalculation time (3rd call)", calculation_time
# fill the cache
original = my_cache(nb_iterations, portal_path=('', portal.getId()))
# Purge the Caching Method
my_cache.delete(nb_iterations, portal_path=('', portal.getId()))
# Check that result is computed
start = time.time()
original = my_cache(nb_iterations, portal_path=('', portal.getId()))
end = time.time()
calculation_time = end-start
print "\n\tCalculation time (4th call)", calculation_time
self.assert_(1.0 < calculation_time)
def test_03_cachePersistentObjects(self):
# storing persistent objects in cache is not allowed, but this check is
# only performed in unit tests.
......
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