根据b站UP主狂神说Redis课程所写的个人学习笔记

视频地址:https://www.bilibili.com/video/BV1S54y1R7SB


Redis发布订阅是一种消息通信模式

Redis客户端可以订阅任意数量的频道

第一个:消息发送者

第二个:频道

第三个:消息订阅者

Redis个人学习笔记9---Redis发布订阅

Redis个人学习笔记9---Redis发布订阅

测试:

订阅端:

127.0.0.1:6379> subscribe lin 
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "lin"
3) (integer) 1
1) "message" #消息
2) "lin" #哪个频道的消息
3) "hello,lin" #具体内容

发送端:

127.0.0.1:6379> publish lin "hello,lin"
(integer) 1

使用场景:

1.实时消息系统

2.实时聊天

3.订阅 关注系统

稍微复杂的场景我们会用消息中间件
 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-12-18
  • 2021-09-27
  • 2021-05-20
  • 2022-03-06
猜你喜欢
  • 2021-11-15
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2021-09-07
  • 2021-10-14
  • 2021-09-30
相关资源
相似解决方案