Commit 3e64c13d authored by Ivan Tyagov's avatar Ivan Tyagov

Removed dependency of memcache module for DistributedRamCache plugin

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11046 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f1e5141e
......@@ -38,6 +38,11 @@ from Products.ERP5Type.CachePlugins.RamCache import RamCache
from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache
from Products.ERP5Type.CachePlugins.SQLCache import SQLCache
## try to import needed modules for cache plugins
try:
import memcache
except ImportError:
pass
class CacheTool(BaseTool):
""" Caches tool wrapper for ERP5 """
......@@ -67,21 +72,30 @@ class CacheTool(BaseTool):
rd[cache_scope]['cache_plugins'] = []
rd[cache_scope]['cache_params'] = {}
for cp in cf.getCachePluginList():
cache_obj = None
cp_meta_type = cp.meta_type
if cp_meta_type == 'ERP5 Ram Cache Plugin':
cache_obj = RamCache()
elif cp_meta_type == 'ERP5 Distributed Ram Cache Plugin':
cache_obj = DistributedRamCache({'server':cp.getServer()})
## even thougn we have such plugin in ZODB that doens't mean
## we have corresponding memcache module installed
if 'memcache' in globals().keys():
cache_obj = DistributedRamCache({'server':cp.getServer()})
else:
## we don't have memcache python module installed
## thus we can't use DistributedRamCache plugin
cache_obj = None
elif cp_meta_type == 'ERP5 SQL Cache Plugin':
## use connection details from 'erp5_sql_transactionless_connection' ZMySLQDA object
connection_string = self.erp5_sql_transactionless_connection.connection_string
kw = self.parseDBConnectionString(connection_string)
kw['cache_table_name'] = cp.getCacheTableName()
cache_obj = SQLCache(kw)
## set cache expire check interval
cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
rd[cache_scope]['cache_plugins'].append(cache_obj)
rd[cache_scope]['cache_params']['cache_duration'] = cf.getCacheDuration()
if cache_obj:
## set cache expire check interval
cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
rd[cache_scope]['cache_plugins'].append(cache_obj)
rd[cache_scope]['cache_params']['cache_duration'] = cf.getCacheDuration()
return rd
##
......
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