python操作memcache
[root@centos7 ~]#cat m.py
#!/usr/bin/env python
#coding:utf-8
import memcache
m = memcache.Client(['127.0.0.1:11211'], debug=True)
for i in range(10):
m.set("key%d" % i,"v%d" % i)
ret = m.get('key%d' % i)
print ret
[root@centos7 ~]#yum -y install python-memcached
[root@centos7 ~]#python m.py
v0
v1
v2
v3
v4
v5
v6
v7
v8
v9
[root@centos7 ~]#telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get key1
VALUE key1 0 2
v1
END
get key9
VALUE key9 0 2
v9
END
get key10
END
quit
Connection closed by foreign host.
[root@centos7 ~]#
本文链接:http://www.yunweipai.com/35193.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52750.html