The Memcached Tool gives access to memcached server as if it were a python
dictionary. Memcached provides a fast but transient storage, compared with
ZODB not-so-fast but persistent and historized storage.
Table of Contents
those requirements may be available as packages for your distribution.
Also don't forget to take a look at Nexedi's repositories where we maintain some packages.
Memcached Tool is automatically enabled if python-memcached library is installed.
First, you must keep in mind that objects stored in memcached can be lost at any
time, because of memcache design. You should therefore never store any valuable
data in memcached without storing it in a safe place. Objects will be deleted
when memcached is stopped or if it runs out of memory (depending on configuration,
see memcached manual). Or you can use 'persistent' variant of memcached like
Here is an example on how to store and retrieve an object using Memcached Tool:
memcached_tool = context.getPortalObject().portal_memcached
memcached_dict = memcached_tool.getMemcachedDict(key_prefix='my_first_test',
value = memcached_dict['some_key']
if value is None:
value = 0
memcached_dict['some_key'] = value + 1
This method takes one argument which allows to uniquely identify the use of
memcached. It is a similar concept to Caching Method
id, and allows multiple concurrent uses of a single memcached server.
Because of python-memcached (and of memcached itself probably) design, you cannot
Because of Memcached Tool design, you must explicitly store any modified objects.
Unlike ZODB, it cannot (yet) detect changes in object's properties.
You can configure the ip:port used by Memcached Tool using its dedicated management
screen, available in your instance at portal_memcached/memcached_tool_configure .