python连接redis发布消息
作者:
大大大大大璐子 | 来源:发表于
2017-12-23 11:29 被阅读0次发布信息
import redis
import time
class RedisPub():
def __init__(self):
pool = redis.ConnectionPool(host='127.0.0.0', port='6379', password='adc123') #连接redis
self._conn = redis.StrictRedis(connection_pool=pool)
self.pub_chan = 'chan_test'
def public(self):
msg = ('要发布的信息内容')
self._conn.publish(self.pub_chan, msg) #发布信息
if __name__ == '__main__':
R = RedisPub()
R.public()
本文标题:python连接redis发布消息
本文链接:https://www.haomeiwen.com/subject/fcnfgxtx.html
网友评论