cJSON
cJSON是一个使用C语言编写的JSON数据解析器,具有超轻便,可移植,单文件的特点,使用MIT开源协议。
cJSON项目托管在Github上,仓库地址如下:
https://github.com/DaveGamble/cJSON
CJSON比JSON速度更快,完善字符格式,推荐使用
CACHED_KEY_PREFIX = "test_server"
class CachedUtils: @classmethod def dumps(cls, obj): return cjson.dumps(obj, 2) @classmethod def loads(cls, str): return cjson.loads(str) @classmethod def lock_key(cls, key): return CACHED_KEY_PREFIX + ':lock:%s' % (key) @classmethod def lock_delete(cls, key, mock = False): get_redis().delete(key) """ lock_key = cls.lock_key(key) with DLockit(get_redis(), lock_key, mock=mock) as locked: if locked: do_something() """
标签:classmethod,Python,lock,cjson,key,序列化,cls From: https://www.cnblogs.com/zhaoyingjie/p/17080779.html