What is it:
A message communication pattern between processes: the sender (pub) sends a message, and the Subscriber (sub) receives the message.
Subscribe/Publish a message map
Before you can receive a message after you have subscribed
1. You can subscribe to multiple, SUBSCRIBE C1 c2 C3
2. News release, PUBLISH C2 Hello-redis
Subscribe First
127.0.0.1:6379> SUBSCRIBE C1 C2 C3
Reading messages ... (Press Ctrl-c to quit)
1) "Subscribe"
2) "C1"
3) (integer) 1
1) "Subscribe"
2) "C2"
3) (integer) 2
1) "Subscribe"
2) "C3"
3) (integer) 3
1) "Message"
Release
127.0.0.1:6379> PUBLISH C2 Hello-redis
(integer) 1
127.0.0.1:6379> PUBLISH C1 hello1122
(integer) 1
127.0.0.1:6379>
Receive Message
127.0.0.1:6379> SUBSCRIBE C1 C2 C3
Reading messages ... (Press Ctrl-c to quit)
1) "Subscribe"
2) "C1"
3) (integer) 1
1) "Subscribe"
2) "C2"
3) (integer) 2
1) "Subscribe"
2) "C3"
3) (integer) 3
1) "Message"
2) "C2"
3) "Hello-redis"
1) "Message"
2) "C1"
3) "hello1122"
======================
3. Subscribe to multiple, wildcard *,psubscribe new*
4. Receive the message, PUBLISH New1 redis2015
127.0.0.1:6379> Psubscribe new*
Reading messages ... (Press Ctrl-c to quit)
1) "Psubscribe"
2) "new*"
3) (integer) 1
1) "Pmessage"
2) "new*"
3) "New1"
4) "redis2015"
1) "Pmessage"
2) "new*"
3) "New2"
4) "redis2016"
127.0.0.1:6379> PUBLISH New1 redis2015
(integer) 1
127.0.0.1:6379> PUBLISH new2 redis2016
(integer) 1
127.0.0.1:6379>
Publication subscriptions for Redis