Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

2.11. 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
		
		

例 2.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")