''' memcached内存数据库 ''' ''' redis集群 redis-py-cluster模块 ''' #from rediscluster import StrictRedisCluster ''' memcached pip install python-memcached memcached -d -m 10 -u root -l 127.0.0.1 -p 12000 -c 256 -P ''' import memcache mc = memcache.Client(['192.168.4.10:12000']) print(mc) mc.set("aaa","hello world") print(mc.get("aaa")) ''' ps -ef | grep memcached memcached -d -m 10 -u root -l 192.168.4.10 -p 12000 -c 256 -P /export/servers/memcache/logs/memcache.pid ps -ef | grep memcached ''' ''' set、add/replace/append/prepand/cas set(key,value) get(key) mc.add("mctestadd","nihao") print(mc.get("mctestadd")) replace(key,new_value) 修改某个key的值,不存在报错 set和add的区别 set = add + replace set_multi({"k1":"v1","k2":"v2","k3":"v3"}) # 一次多个值 删除 delete(key) delete_multi([k1,k2,k3]) 获取 get(key) get_multi([k1,k2,k3]) mc.append("aaa","321") #key的后面追加 print(mc.get("aaa")) mc.prepend("aaa","556") #key的前面追加 print(mc.get("aaa")) print(mc.stats) ''' ''' stats gets cas '''
转载于:https://my.oschina.net/u/3824134/blog/1815731