python操作redis-事务

时间:2016-04-21 10:05:39   收藏:0   阅读:1221
#!/usr/bin/python
#!coding: utf-8

import redis
import sys

if __name__=="__main__":
    try:
        conn=redis.StrictRedis(‘192.168.80.41‘)
        pipe=conn.pipeline()
        pipe.sadd(‘s001‘,‘a‘)
        sys.exit()
        #在事务还没有提交前退出,所以事务不会被执行。
        pipe.sadd(‘s001‘,‘b‘)
        pipe.execute()
        pass
    except Exception as err:
        print(err)
        pass

 

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!