diff --git a/product/ERP5Type/Cache.py b/product/ERP5Type/Cache.py index 84c03a2c6c6bcc4a40042a4b7ab0b769de354477..ba0925ae60a8cc66d6607f4b2d58bd6e6214196a 100644 --- a/product/ERP5Type/Cache.py +++ b/product/ERP5Type/Cache.py @@ -243,9 +243,11 @@ def disableReadOnlyTransactionCache(context): ## TODO: Check if it make sense to keep them any more ## ######################################################## -def clearCache(): - """Clear the whole cache. """ - for cf_obj in CachingMethod.factories.values(): - for cp in cf_obj.getCachePluginList(): - cp.clearCache() +def clearCache(cache_factory_list=(DEFAULT_CACHE_FACTORY,)): + """Clear specified cache factory list.""" + cache_storage = CachingMethod.factories + for cf_key in cache_factory_list: + if cache_storage.has_key(cf_key): + for cp in cache_storage[cf_key].getCachePluginList(): + cp.clearCache() diff --git a/product/ERP5Type/Tool/CacheTool.py b/product/ERP5Type/Tool/CacheTool.py index def234d218a8385bdf47249309cf4919eec604a1..e0d1fe859ee085ccd9cbe9c12bfa5e22f9aad6ec 100644 --- a/product/ERP5Type/Tool/CacheTool.py +++ b/product/ERP5Type/Tool/CacheTool.py @@ -33,7 +33,7 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type import Permissions from Globals import InitializeClass, DTMLFile, PersistentMapping from Products.ERP5Type import _dtmldir -from Products.ERP5Type.Cache import CachingMethod, CacheFactory +from Products.ERP5Type.Cache import * from Products.ERP5Type.CachePlugins.RamCache import RamCache from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache from Products.ERP5Type.CachePlugins.SQLCache import SQLCache @@ -175,12 +175,13 @@ class CacheTool(BaseTool): self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache updated.') security.declareProtected(Permissions.ModifyPortalContent, 'clearCache') - def clearCache(self, REQUEST=None): - """ Clear whole cache structure """ + def clearCache(self, cache_factory_list=(DEFAULT_CACHE_FACTORY,), REQUEST=None): + """ Clear cache factory. """ ram_cache_root = self.getRamCacheRoot() - for cf in ram_cache_root: - for cp in ram_cache_root[cf].getCachePluginList(): - cp.clearCache() + for cf_key in cache_factory_list: + if ram_cache_root.has_key(cf_key): + for cp in ram_cache_root[cf_key].getCachePluginList(): + cp.clearCache() if REQUEST is not None: self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache cleared.')