[Erp5-report] r34779 nicolas - in /erp5/trunk/products/ERP5Type: CachePlugins/ PropertyShee...
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Apr 26 14:40:06 CEST 2010
Author: nicolas
Date: Mon Apr 26 14:40:03 2010
New Revision: 34779
URL: http://svn.erp5.org?rev=34779&view=rev
Log:
Add expiration_time property on MemcachedPlugin to support expiration feature
of memcached protocol.
Extend MemcahedTool and MemcachedDict API to handle expiration_time parameter.
Note that CacheTool implement this feature through CacheEntry API.
Modified:
erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
erp5/trunk/products/ERP5Type/PropertySheet/MemcachedPlugin.py
erp5/trunk/products/ERP5Type/Tool/CacheTool.py
erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py
Modified: erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py?rev=34779&r1=34778&r2=34779&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/DistributedRamCache.py [utf8] Mon Apr 26 14:40:03 2010
@@ -57,6 +57,7 @@
def __init__(self, params={}):
self._servers = params.get('server', '')
+ self._expiration_time = params.get('expiration_time', 0)
self._server_max_key_length = params.get('server_max_key_length', 250)
self._server_max_value_length = params.get('server_max_value_length', 1024*1024)
self._debug_level = params.get('debug_level', 0)
@@ -71,7 +72,8 @@
def _getMemcachedDict(self):
"""return a threading safe MemcachedDict instance
"""
- configuration_key = (self._servers, self._server_max_key_length,
+ configuration_key = (self._servers, self._expiration_time,
+ self._server_max_key_length,
self._server_max_value_length,
self._debug_level, self._key_prefix)
try:
Modified: erp5/trunk/products/ERP5Type/PropertySheet/MemcachedPlugin.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/PropertySheet/MemcachedPlugin.py?rev=34779&r1=34778&r2=34779&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/PropertySheet/MemcachedPlugin.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/PropertySheet/MemcachedPlugin.py [utf8] Mon Apr 26 14:40:03 2010
@@ -44,5 +44,11 @@
'default' : 1048576,
'mode' : 'w' ,
},
+ {'id' : 'expiration_time',
+ 'description' : 'Time to live of stored value (in second)',
+ 'type' : 'int',
+ 'default' : 0,
+ 'mode' : 'w' ,
+ },
)
Modified: erp5/trunk/products/ERP5Type/Tool/CacheTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/CacheTool.py?rev=34779&r1=34778&r2=34779&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/CacheTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/CacheTool.py [utf8] Mon Apr 26 14:40:03 2010
@@ -89,6 +89,7 @@
server = memcached_plugin.getUrlString('')
init_dict = {
'server': server,
+ 'expiration_time': cf.getCacheDuration(),
'server_max_key_length': memcached_plugin.getServerMaxKeyLength(),
'server_max_value_length': memcached_plugin.getServerMaxValueLength(),
'key_prefix': getattr(self, 'erp5_site_global_id', '')
Modified: erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py?rev=34779&r1=34778&r2=34779&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py [utf8] Mon Apr 26 14:40:03 2010
@@ -75,8 +75,8 @@
- make picklable ?
"""
- def __init__(self, server_list=('127.0.0.1:11211',), server_max_key_length=MARKER,
- server_max_value_length=MARKER):
+ def __init__(self, server_list=('127.0.0.1:11211',), expiration_time=0,
+ server_max_key_length=MARKER, server_max_value_length=MARKER):
"""
Initialise properties :
memcached_connection
@@ -96,6 +96,7 @@
self.scheduled_action_dict = {}
init_dict = {}
self.server_list = server_list
+ self.expiration_time = expiration_time
if server_max_key_length is not MARKER:
init_dict['server_max_key_length'] = server_max_key_length
if server_max_value_length is not MARKER:
@@ -122,7 +123,9 @@
self.scheduled_action_dict[key] = UPDATE_ACTION
for key, action in self.scheduled_action_dict.iteritems():
if action is UPDATE_ACTION:
- succeed = self.memcached_connection.set(encodeKey(key), self.local_cache[key], 0)
+ succeed = self.memcached_connection.set(encodeKey(key),
+ self.local_cache[key],
+ self.expiration_time)
if not succeed:
LOG('MemcacheTool', 0, 'set command to memcached server (%r) failed' % (self.server_list,))
elif action is DELETE_ACTION:
@@ -289,6 +292,7 @@
if memcached_plugin is None:
raise ValueError, 'Memcached Plugin does not exists: %r' % (plugin_path,)
dictionary = MemcachedDict((memcached_plugin.getUrlString(''),),
+ expiration_time=memcached_plugin.getExpirationTime(),
server_max_key_length=memcached_plugin.getServerMaxKeyLength(),
server_max_value_length=memcached_plugin.getServerMaxValueLength())
local_dict[plugin_path] = dictionary
More information about the Erp5-report
mailing list