Commit caec6a45 authored by Ivan Tyagov's avatar Ivan Tyagov

Do not clear whole cache - only specified or default ERP5 one factory because...

Do not clear whole cache - only specified or default ERP5 one factory because some third parties can have their own cache factories.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12105 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2fc10fb1
......@@ -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():
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()
......@@ -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,11 +175,12 @@ 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():
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.')
......
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