Commit 121ed7eb authored by Nicolas Delaby's avatar Nicolas Delaby

Implement new ZODB Cache

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26986 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent be260cdb
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
......@@ -47,6 +48,7 @@ class CacheFactory(XMLObject):
allowed_types = ('ERP5 Ram Cache',
'ERP5 Distributed Ram Cache',
'ERP5 SQL Cache',
'ERP5 Zodb Cache',
)
security = ClassSecurityInfo()
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
......@@ -39,6 +40,7 @@ from Products.ERP5Type.Cache import DEFAULT_CACHE_FACTORY
from Products.ERP5Type.CachePlugins.RamCache import RamCache
from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache
from Products.ERP5Type.CachePlugins.SQLCache import SQLCache
from Products.ERP5Type.CachePlugins.ZODBCache import ZODBCache
## try to import needed modules for cache plugins
try:
......@@ -100,7 +102,9 @@ class CacheTool(BaseTool):
kw = self.parseDBConnectionString(connection_string)
kw['cache_table_name'] = cp.getCacheTableName()
cache_obj = SQLCache(kw)
if cache_obj:
elif cp_meta_type == 'ERP5 Zodb Cache':
cache_obj = ZODBCache(dict(cache_tool=self))
if cache_obj is not None:
## set cache expire check interval
cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
rd[cache_scope]['cache_plugins'].append(cache_obj)
......
......@@ -75,6 +75,7 @@ class TestCacheTool(ERP5TypeTestCase):
"Ram Cache",
"Distributed Ram Cache",
"SQL Cache",
"Zodb Cache",
)
for typeinfo_name in typeinfo_names:
portal_type = getattr(portal_types, typeinfo_name, None)
......@@ -111,6 +112,14 @@ class TestCacheTool(ERP5TypeTestCase):
portal_type="SQL Cache", container=sql_cache_factory)
sql_cache_plugin.setIntIndex(0)
## zodb_cache_factory (to test ZODB Cache Plugin)
zodb_cache_factory = portal_caches.newContent(portal_type="Cache Factory",
id='zodb_cache_factory',
container=portal_caches)
zodb_cache_plugin = zodb_cache_factory.newContent(
portal_type="Zodb Cache", container=zodb_cache_factory)
zodb_cache_plugin.setIntIndex(0)
## erp5_user_factory (to test a combination of all cache plugins)
erp5_user_factory = portal_caches.newContent(portal_type="Cache Factory",
id="erp5_user_factory",
......@@ -125,18 +134,24 @@ class TestCacheTool(ERP5TypeTestCase):
sql_cache_plugin = erp5_user_factory.newContent(
portal_type="SQL Cache", container=erp5_user_factory)
sql_cache_plugin.setIntIndex(2)
zodb_cache_plugin = erp5_user_factory.newContent(
portal_type="Zodb Cache", container=erp5_user_factory)
zodb_cache_plugin.setIntIndex(3)
##
transaction.commit()
## update Ram Cache structure
portal_caches.updateCache()
## commit PersistantMapping for zodb_cache
transaction.commit()
from Products.ERP5Type.Cache import CachingMethod
## do we have the same structure we created above?
self.assert_('ram_cache_factory' in CachingMethod.factories)
self.assert_('distributed_ram_cache_factory' in CachingMethod.factories)
self.assert_('sql_cache_factory' in CachingMethod.factories)
self.assert_('zodb_cache_factory' in CachingMethod.factories)
self.assert_('erp5_user_factory' in CachingMethod.factories)
def test_04_CreateCachedMethod(self):
......@@ -172,7 +187,8 @@ return result
py_script_obj = getattr(portal, py_script_id)
for cf_name in ('ram_cache_factory',
'distributed_ram_cache_factory',
'sql_cache_factory'):
'sql_cache_factory',
'zodb_cache_factory',):
my_cache = CachingMethod(py_script_obj,
'py_script_obj',
cache_factory=cf_name)
......
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