Implementing PubSub with Redis
Redis exposes a Publish-Subscribe messaging pattern (not so dissimilar to the CouchDB changes stream), which can be used to listen to specific data change events. Data from these events could be passed between processes to, for instance, instantly update a web app with fresh new data.
With PubSub, we publish a message to a specific channel, this channel can then be picked up by any amount of subscribers. The publishing mechanism doesn't care who's listening or how many, it chats away regardless.
In this recipe, we will create a publishing process and a subscribing process. For publishing, we'll extend our quotes.js file from the previous recipe Storing and retrieving data with Redis, and we'll write the code to a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access