Home | Mirror | Search | 杂文 | ITEYE 博客 | OSChina 博客 | 51CTO 博客

9.6. python-memcached

参考Python安装
wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-1.34.tar.gz
tar zxvf python-memcached-1.34.tar.gz
cd python-memcached-1.34
		

# python setup.py install

running install
running build
running build_py
creating build
creating build/lib
copying memcache.py -> build/lib
running install_lib
copying build/lib/memcache.py -> /usr/lib/python2.3/site-packages
byte-compiling /usr/lib/python2.3/site-packages/memcache.py to memcache.pyc

		

例 9.1. memcached.py

import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=1)

mc.set("some_key", "Some value")
value = mc.get("some_key")
print value

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")
			

comments powered by Disqus