1.安装Python-memcached
-
wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-1.53.tar.gz
-
然后解压进入目录
-
python setup.py install --进行安装
注意上面执行python setup.py install 安装之前需要先把python-setuptools安装上,不然会报错误说
Traceback (most recent call last):
File "setup.py", line 3, in
from setuptools import setup
ImportError: No module named setuptools
解决办法很简单,只要yum install python-setuptools就可以了。
然后我们进行简单的测试:
-
#!/usr/bin/env python
-
import memcache
-
-
pymem = memcache.Client(['x.x.x.x:11211'],debug=0)
-
pymem.set("key5","hello,memcache!")
-
value = pymem.get("key5")
-
print value
执行结果如下:
阅读(1981) | 评论(0) | 转发(0) |