首页 > 代码库 > redis实现发布订阅

redis实现发布订阅

订阅者

 1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 import redis 4  5 r = redis.Redis(host=192.168.11.119) 6 pub = r.pubsub() 7 pub.subscribe(fm9999) 8 while True: 9     msg= pub.parse_response()10     print(msg)

发布者

1 #!/usr/bin/env python2 # -*- coding:utf-8 -*-3 import redis4 5 r = redis.Redis(host=192.168.11.119)6 r.publish(fm9999, sb)

 

redis实现发布订阅