[Erp5-report] r28482 - in /erp5/trunk/products/ERP5Type: CachePlugins/ Tool/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Aug 20 11:42:38 CEST 2009


Author: nicolas
Date: Thu Aug 20 11:42:37 2009
New Revision: 28482

URL: http://svn.erp5.org?rev=28482&view=rev
Log:
Add a prefix to build the key of DistributedRamCache with
 - erp5_site_global_id: a site property.
 - cache_plugin_path: path of the cache plugin itself.
This is usefull to share the same memcached server for multiple instances.

Modified:
    erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.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=28482&r1=28481&r2=28482&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] Thu Aug 20 11:42:37 2009
@@ -60,6 +60,7 @@
     self._server_max_value_length = params.get('server_max_value_length', 1024*1024)
     self._debug_level = params.get('debug_level', 0)
     self._key_prefix = params.get('key_prefix', '')
+    self._cache_plugin_path = params.get('cache_plugin_path')
     BaseCache.__init__(self)
 
   def initCacheStorage(self):
@@ -91,7 +92,8 @@
   def checkAndFixCacheId(self, cache_id, scope):
     ## memcached doesn't support namespaces (cache scopes) so to "emmulate"
     ## such behaviour when constructing cache_id we add scope in front
-    cache_id = "%s%s.%s" % (self._key_prefix, scope, cache_id)
+    cache_id = "%s%s%s%s" % (self._key_prefix, self._cache_plugin_path,
+                             scope, cache_id)
     if self._server_max_key_length != 0:
       ## memcached will fail to store cache_id longer than MEMCACHED_SERVER_MAX_KEY_LENGTH.
       return cache_id[:self._server_max_key_length]

Modified: erp5/trunk/products/ERP5Type/Tool/CacheTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/CacheTool.py?rev=28482&r1=28481&r2=28482&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/CacheTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/CacheTool.py [utf8] Thu Aug 20 11:42:37 2009
@@ -91,6 +91,8 @@
                 'server': server,
                 'server_max_key_length': memcached_plugin.getServerMaxKeyLength(),
                 'server_max_value_length': memcached_plugin.getServerMaxValueLength(),
+                'cache_plugin_path': cp.getPath(),
+                'key_prefix': getattr(self, 'erp5_site_global_id', '')
                             }
               cache_obj = DistributedRamCache(init_dict)
         if cache_obj is not None:




More information about the Erp5-report mailing list