def python_memcache_serializer(key, value):
flags = 0
if isinstance(value, str):
pass
elif isinstance(value, int):
flags |= FLAG_INTEGER
value = "%d" % value
elif isinstance(value, long):
flags |= FLAG_LONG
value = "%d" % value
else:
flags |= FLAG_PICKLE
output = StringIO()
pickler = pickle.Pickler(output, 0)
pickler.dump(value)
value = output.getvalue()
return value, flags
评论列表
文章目录