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