0
0
Redisquery~20 mins

PUBLISH to channels in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Pub/Sub Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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!"
Anull
B1
CError: no subscribers
D0
Attempts:
2 left
💡 Hint
Think about how many clients are subscribed to the channel at the time of publishing.
query_result
intermediate
2: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"
A2
B3
C1
D0
Attempts:
2 left
💡 Hint
The output is the count of subscribers that receive the message.
📝 Syntax
advanced
2:00remaining
Which PUBLISH command syntax is correct?
Identify the correct syntax to publish the message "Hello" to the channel "chat" in Redis.
APUBLISH chat "Hello"
BPUBLISH "chat" "Hello"
CPUBLISH chat Hello
DPUBLISH "chat" Hello
Attempts:
2 left
💡 Hint
Channel names do not require quotes but messages with spaces or special characters do.
🧠 Conceptual
advanced
2: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?
AThe client receives the message only if published to 'updates'
BThe client receives messages from all channels regardless of publish
CThe client receives the message published to 'news' channel
DThe client receives no messages
Attempts:
2 left
💡 Hint
Think about how subscriptions work per channel.
🔧 Debug
expert
3: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?
Redis
SUBSCRIBE updates
PUBLISH updates "New version released"
AThe subscriber is blocked and cannot receive messages because SUBSCRIBE is a blocking command
BThe channel name 'updates' is reserved and cannot be used
CThe PUBLISH command syntax is incorrect
DRedis server does not support PUBLISH/SUBSCRIBE
Attempts:
2 left
💡 Hint
Consider how SUBSCRIBE affects the client connection.