首页 > 其他 > 详细

redis加分布式锁

时间:2018-06-01 13:09:59      阅读:211      评论:0      收藏:0      [点我收藏+]
def lock_order(fn):
def _warps(*args, **kwargs):
pre = cache.get("lock_order", 0)
if pre:
print "get_order_process is locked---"
return 0
version = str(datetime.now())
cache.set("lock_order", version, 30)
try:
result = fn(*args, **kwargs)
except Exception, e:
print("lock_get_order Exception:%s" % e)
result = -1
cache.delete("lock_order")
return result
return _warps

redis加分布式锁

原文:https://www.cnblogs.com/ilovewuzhaoxia/p/9121027.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!