Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nooperpudd/06c5cda225c3bac68bb583a5e2ad3710 to your computer and use it in GitHub Desktop.
Save nooperpudd/06c5cda225c3bac68bb583a5e2ad3710 to your computer and use it in GitHub Desktop.
.. with r.pipeline() as pipe:
... while 1:
... try:
... # 关注一个key
... pipe.watch('xiaorui.cc')
... current_value = pipe.get('xiaorui.cc')
... next_value = int(current_value) + 1
... #事物开始
... pipe.multi()
... pipe.set('xiaorui.cc', next_value)
... # 事务结束
... pipe.execute()
... # 把命令推送过去
... break
... except WatchError:
... #如果客户端有变动的话,那么就会触发这个异常。
... continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment