Publish and subscribe
A messaging mode of communication between processes: publisher sends a message, subscribers receive messages
Subscribers subscribe to a plurality of receiving a one-time message
1 127.0.0.1:6379> SUBSCRIBE c1 c2 c3 2 Reading messages... (press Ctrl-C to quit) 3 1) "subscribe" 4 2) "c1" 5 3) (integer) 1 6 1) "subscribe" 7 2) "c2" 8 3) (integer) 2 9 1) "subscribe" 10 2) "c3" 11 3) (integer) 3 12 1) "message" 13 2) "c2" 14 3) "woshiniba" 15 1) "message" 16 2) "c1" 17 3) "woshinidie" 18 # -----------------------------通配符*------------------- 19 127.0.0.1:6379> PSUBSCRIBE new* 20 Reading messages... (press Ctrl-C to quit) 21 1) "psubscribe" 22 2) "new*" 23 3) (integer) 1 24 1) " PMessage " 25 2) " new new * " 26 is . 3) " new13 " 27 . 4) " nishishabi " 28 29 # publisher sends a message 30 127.0.0.1:6379> the PUBLISH C2 woshiniba 31 is (Integer). 1 32 127.0.0.1:6379 > the PUBLISH C1 woshinidie 33 is (Integer). 1 34 is # ----------------------- wildcard --------------- ----------- 35 127.0.0.1:6379> the PUBLISH new13 nishishabi 36 (Integer). 1
Related instructions https://www.runoob.com/redis/redis-pub-sub.html