发布时间:2019-08-09 08:50:59编辑:auto阅读(2413)
from pymemcache.client.base import Client
client = Client(('localhost', 11211))
client.set('some_key', 'some_value')
result = client.get('some_key')
from pymemcache.client.hash import HashClient
client = HashClient([('127.0.0.1', 11211),('127.0.0.1', 11212)])
client.set('some_key', 'some value')
result = client.get('some_key')
import json
from pymemcache.client.base import Client
def json_serializer(key, value):if type(value)== str:return value, 1
return json.dumps(value), 2
def json_deserializer(key, value, flags):if flags == 1:return value
if flags == 2:return json.loads(value)raiseException("Unknown serialization format")
client = Client(('localhost', 11211), serializer=json_serializer,
deserializer=json_deserializer)
client.set('key',{'a':'b', 'c':'d'})
result = client.get('key')
上一篇: rails3的render(:updat
下一篇: ubuntu 的3D效果
48881
47956
38733
35872
30296
27057
26081
20915
20725
19088
542°
627°
630°
636°
606°
587°
663°
729°
852°
972°