Challenge - 5 Problems
Redis Pub/Sub Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this PUBLISH command?
Consider a Redis server with no subscribers currently connected. What will be the output of the following command?
PUBLISH news "Breaking news!"Redis
PUBLISH news "Breaking news!"Attempts:
2 left
💡 Hint
Think about how many clients are subscribed to the channel at the time of publishing.
✗ Incorrect
The PUBLISH command returns the number of clients that received the message. If no clients are subscribed, it returns 0.
❓ query_result
intermediate2:00remaining
How many clients receive the message?
Assume three clients are subscribed to the channel 'sports'. What will be the output of this command?
PUBLISH sports "Game tonight at 8pm"Redis
PUBLISH sports "Game tonight at 8pm"Attempts:
2 left
💡 Hint
The output is the count of subscribers that receive the message.
✗ Incorrect
The PUBLISH command returns the number of clients subscribed to the channel, which is 3 in this case.
📝 Syntax
advanced2:00remaining
Which PUBLISH command syntax is correct?
Identify the correct syntax to publish the message "Hello" to the channel "chat" in Redis.
Attempts:
2 left
💡 Hint
Channel names do not require quotes but messages with spaces or special characters do.
✗ Incorrect
The correct syntax is PUBLISH channel message. The channel name can be unquoted if it has no spaces, but the message should be quoted if it contains spaces or special characters.
🧠 Conceptual
advanced2:00remaining
What happens if a client subscribes to multiple channels and a message is published?
If a client is subscribed to channels 'news' and 'updates', and a message is published to 'news', what will the client receive?
Attempts:
2 left
💡 Hint
Think about how subscriptions work per channel.
✗ Incorrect
A client subscribed to multiple channels receives messages only from the channels where messages are published. Here, the client will receive messages published to 'news'.
🔧 Debug
expert3:00remaining
Why does this PUBLISH command fail to deliver messages?
A developer runs the following commands:
1. SUBSCRIBE updates
2. PUBLISH updates "New version released"
But the subscriber never receives the message. What is the most likely reason?
1. SUBSCRIBE updates
2. PUBLISH updates "New version released"
But the subscriber never receives the message. What is the most likely reason?
Redis
SUBSCRIBE updates
PUBLISH updates "New version released"Attempts:
2 left
💡 Hint
Consider how SUBSCRIBE affects the client connection.
✗ Incorrect
SUBSCRIBE puts the client into a mode where it only listens for messages and blocks other commands. If the same client tries to publish, it will not work as expected.