标签:
#!/usr/env/bin python import redis r=redis.Redis(host=‘localhost‘,port=6379,db=0) with r.pipeline() as pipe: while 1: try: pipe.watch(‘OUR-SEQUENCE-KEY‘) current_value=pipe.get(‘OUR-SEQUENCE-KEY‘) next_value=int(current_value)+1 pipe.multi() pipe.set(‘OUR-SEQUENCE-KEY‘,next_value) pipe.execute() break except WatchError: continue
标签:
原文地址:http://my.oschina.net/u/1866459/blog/511211