Created
May 15, 2018 01:35
-
-
Save nooperpudd/06c5cda225c3bac68bb583a5e2ad3710 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.. 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