Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Subscribe Command

Redis Subscribe Command

Redis Publish/Subscribe

The Redis Subscribe command is used to subscribe to messages from one or more given channels.

Syntax

The basic syntax of the redis Subscribe command is as follows:



redis 127.0.0.1:6379> SUBSCRIBE channel [channel ...]

Available Version

= 2.0.0

Return Value

The received message

Example



redis 127.0.0.1:6379> SUBSCRIBE mychannel 

Reading messages... (press Ctrl-C to quit)

1) "subscribe"

2) "mychannel"

3) (integer) 1

1) "message"

2) "mychannel"

3) "a"

Redis Publish/Subscribe