redis Pub/Sub

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

Redis provides an implementation of the Publish/Subscribe (Pub/Sub) messaging pattern. Instead of sending messages to specific receivers, Publishers send messages to interested receivers via some indirection mechanism. Receivers specify interest in particular messages. In Redis this functionality is accessed using the PUBLISH and SUBSCRIBE commands on channels.

Syntax

  • SUBSCRIBE channel [channel ...]
  • UNSUBSCRIBE [channel [channel ...]]
  • PUBLISH channel message
  • PSUBSCRIBE pattern [pattern ...]
  • PUNSUBSCRIBE [pattern [pattern ...]]

Remarks

To handle the pub/sub in redis, need to have one client for subscribe & different client for publish. Both can't be handled by same client. Though all other commands can be still handled with same client.



Got any redis Question?