[Erp5-report] r11204 - in /erp5/trunk/products/ERP5Type: CachePlugins/ Tool/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Nov 8 14:29:51 CET 2006
Author: ivan
Date: Wed Nov 8 14:29:41 2006
New Revision: 11204
URL: http://svn.erp5.org?rev=11204&view=rev
Log:
Added initCacheStorage method which will init (if needed) cache backend storage when cache is updated
Modified:
erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py
erp5/trunk/products/ERP5Type/CachePlugins/SQLCache.py
erp5/trunk/products/ERP5Type/Tool/CacheTool.py
Modified: erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py?rev=11204&r1=11203&r2=11204&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py Wed Nov 8 14:29:41 2006
@@ -52,6 +52,11 @@
self._debugLevel = params.get('debugLevel', 7)
self._last_cache_conn_creation_time = time()
BaseCache.__init__(self)
+
+ def initCacheStorage(self):
+ """ Init cache storage """
+ ## cache storage is a memcached server and no need to init it
+ pass
def getCacheStorage(self):
## if we use one connection object this causes
Modified: erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py?rev=11204&r1=11203&r2=11204&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py Wed Nov 8 14:29:41 2006
@@ -42,7 +42,12 @@
def __init__(self, params={}):
BaseCache.__init__(self)
-
+
+ def initCacheStorage(self):
+ """ Init cache storage """
+ ## cache storage is a RAM based dictionary
+ pass
+
def getCacheStorage(self):
return self._cache_dict
Modified: erp5/trunk/products/ERP5Type/CachePlugins/SQLCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CachePlugins/SQLCache.py?rev=11204&r1=11203&r2=11204&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/SQLCache.py (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/SQLCache.py Wed Nov 8 14:29:41 2006
@@ -105,7 +105,9 @@
FROM %s
WHERE scope="%s"
'''
-
+
+ find_table_by_name_sql = """SHOW TABLES LIKE '%s' """
+
def __init__(self, params):
BaseCache.__init__(self)
self._dbConn = None
@@ -117,7 +119,19 @@
## since SQL cache is persistent check for expired objects
#self.expireOldCacheEntries(forceCheck=True)
-
+
+ def initCacheStorage(self):
+ """ Init cache backedn storage by creating needed cache table in RDBMS """
+ sql_query = self.find_table_by_name_sql %self._db_cache_table_name
+ cursor = self.execSQLQuery(sql_query)
+ result = cursor.fetchall()
+ if 0 < len(result):
+ ## we have such table
+ pass
+ else:
+ ## no such table create it
+ self.execSQLQuery(self.create_table_sql %self._db_cache_table_name)
+
def getCacheStorage(self):
"""
Return current DB connection or create a new one for this thread.
@@ -139,7 +153,6 @@
else:
## we have already dbConn for this thread
return dbConn
-
def get(self, cache_id, scope, default=None):
sql_query = self.get_key_sql %(self._db_cache_table_name, cache_id, scope)
Modified: erp5/trunk/products/ERP5Type/Tool/CacheTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/CacheTool.py?rev=11204&r1=11203&r2=11204&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/CacheTool.py (original)
+++ erp5/trunk/products/ERP5Type/Tool/CacheTool.py Wed Nov 8 14:29:41 2006
@@ -160,14 +160,16 @@
security.declareProtected(Permissions.ModifyPortalContent, 'updateCache')
def updateCache(self, REQUEST=None):
""" Clear and update cache structure """
- #erp5_site_id = self.getPortalObject().getId()
for cf in CachingMethod.factories:
- for cp in CachingMethod.factories[cf].getCachePluginList():
+ for cp in CachingMethod.factories[cf].getCachePluginList():
del cp
CachingMethod.factories = {}
## read configuration from ZODB
for key,item in self.getCacheFactoryList().items():
if len(item['cache_plugins'])!=0:
+ ## init cache backend storages
+ for cp in item["cache_plugins"]:
+ cp.initCacheStorage()
CachingMethod.factories[key] = CacheFactory(item['cache_plugins'], item['cache_params'])
if REQUEST is not None:
self.REQUEST.RESPONSE.redirect('cache_tool_configure?portal_status_message=Cache updated.')
More information about the Erp5-report
mailing list