Это довольно просто. Вы пишете значения с помощью ключей и времени истечения. Вы получаете значения, используя ключи. Вы можете истечь ключи от системы.
Большинство клиентов придерживаются тех же правил. Вы можете прочитать общие инструкции и рекомендации по the memcached homepage.
Если вы действительно хотите копаться в нем, я бы посмотрел на источник. Вот комментарий Заголовок:
"""
client module for memcached (memory cache daemon)
Overview
========
See U{the MemCached homepage<http://www.danga.com/memcached>} for more about memcached.
Usage summary
=============
This should give you a feel for how this module operates::
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=0)
mc.set("some_key", "Some value")
value = mc.get("some_key")
mc.set("another_key", 3)
mc.delete("another_key")
mc.set("key", "1") # note that the key used for incr/decr must be a string.
mc.incr("key")
mc.decr("key")
The standard way to use memcache with a database is like this::
key = derive_key(obj)
obj = mc.get(key)
if not obj:
obj = backend_api.get(...)
mc.set(key, obj)
# we now have obj, and future passes through this code
# will use the object from the cache.
Detailed Documentation
======================
More detailed documentation is available in the L{Client} class.
"""
Спасибо, комментарии исходного кода очень полезны. –
Я не могу понять, что такое «mc». Не могли бы вы объяснить? – bodacydo
'mc' - это объект Client Memcache, он представляет собой memcached-соединение. – moshen