Recall & Review
beginner
What does the PUBLISH command do in Redis?
The PUBLISH command sends a message to all subscribers of a given channel. It is used to broadcast messages in Redis's pub/sub system.
Click to reveal answer
beginner
How do subscribers receive messages in Redis?
Subscribers use the SUBSCRIBE command to listen to channels. When a message is published to those channels, subscribers receive the message instantly.
Click to reveal answer
beginner
What is the syntax of the PUBLISH command?
PUBLISH <channel> <message> — where <channel> is the name of the channel and <message> is the text to send.
Click to reveal answer
intermediate
Can PUBLISH send messages to multiple channels at once?
No, PUBLISH sends a message to one channel at a time. To send to multiple channels, you must call PUBLISH separately for each channel.
Click to reveal answer
intermediate
What happens if no clients are subscribed to a channel when a message is published?
The message is simply discarded. Redis does not store messages for channels; only active subscribers receive messages.
Click to reveal answer
What command do you use to send a message to subscribers in Redis?
✗ Incorrect
PUBLISH sends messages to subscribers on a channel.
If no clients are subscribed to a channel, what happens to a published message?
✗ Incorrect
Redis does not store messages; they are discarded if no subscribers exist.
Which command do clients use to listen to messages on a channel?
✗ Incorrect
SUBSCRIBE lets clients listen to messages on channels.
Can the PUBLISH command send a message to multiple channels in one call?
✗ Incorrect
PUBLISH sends to one channel at a time.
What is the correct syntax to publish 'hello' to channel 'news'?
✗ Incorrect
PUBLISH is the correct syntax.
Explain how Redis pub/sub works with PUBLISH and SUBSCRIBE commands.
Think of a radio station broadcasting to listeners.
You got /4 concepts.
Describe what happens when you publish a message to a channel with no subscribers.
Imagine shouting in an empty room.
You got /4 concepts.