Redis: Redis Publish/subscribe

Redis implements a publish/subscribe messaging mechanism.

Its concept is simple: a publisher sends a message on a channel. Multiple subscribers receive it.

Subscribe to a channel using

SUBSCRIBE <channel>

Publish to a channel using

PUBLISH <channel> <message>

Example:

SUBSCRIBE dogs

In another redis-cli window, type:

PUBLISH dogs "Roger"

Messages will be sent to the subscribers, and they’ll by default display the kind of event, the channel, and the message:

Subscribers can listen on multiple channels:

SUBSCRIBE dogs cats

and will receive messages coming from all of them.

Lessons in this unit:

0: Introduction
1: Introduction to Redis
2: How to install Redis
3: First steps with Redis
4: Redis Lists
5: Using Redis Sets
6: How to use Redis Sorted Lists
7: How to use Redis Hashes
8: ▶︎ Redis Publish/subscribe
9: How to use Redis from Node.js

Join my AI Workshop!

The Web Development BOOTCAMP cohort starts in February 2026