9951 explained code solutions for 126 technologies


python-redisRedis pubsub publish example


This is messages listener that subscribes to specified channel and waits for messages infinitely:

r = redis.Redis()
r.publish('test', 'hi')ctrl + c
redis.Redis

connect to Redis server

publish

publish message to the specified channel

'test'

name of the channel to publish message to

'hi'

message to publish