当前位置:网站首页>[redis] publish and subscribe

[redis] publish and subscribe

2022-06-22 21:09:00 fate _ zore

Publish and subscribe

What is publish and subscribe

Redis Publish subscribe (pub/sub) It's a message communication mode : sender (pub) Send a message , subscriber (sub) receive messages .

Redis Clients can subscribe to any number of channels .

Redis Publish and subscribe to

The client can subscribe to channels, as shown in the figure below

image-20220617162250190

When you post a message to this channel , The message is sent to the subscribing client

image-20220617162502192

Publish and subscribe command line implementation

  1. Open a client subscription channel1
  2. image-20220617162937844
  3. command :SUBSCRIBE channel1
  4. Open another client , to channel1 Release the news
  5. image-20220617162915865
  6. command :publish channel1 hello
  7. image-20220617162951740
原网站

版权声明
本文为[fate _ zore]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221944520486.html