0
0
Redisquery~20 mins

SUBSCRIBE 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
1:30remaining
What is the output of subscribing to a single channel?
You run the command SUBSCRIBE news in Redis CLI. What will be the first message you receive?
Redis
SUBSCRIBE news
A["unsubscribe", "news", 0]
B["message", "news", "Hello World"]
C["error", "unknown command"]
D["subscribe", "news", 1]
Attempts:
2 left
💡 Hint
When you subscribe, Redis confirms the subscription first.
query_result
intermediate
1:30remaining
What happens when you subscribe to multiple channels?
You run SUBSCRIBE sports weather. What is the output after subscribing?
Redis
SUBSCRIBE sports weather
A["subscribe", "sports", 1]
B["subscribe", "sports", 2]
C["subscribe", "weather", 2]
D["message", "sports", "Game tonight"]
Attempts:
2 left
💡 Hint
Redis sends a confirmation for each channel subscribed, increasing the count.
📝 Syntax
advanced
2:00remaining
Which command syntax correctly subscribes to channels with patterns?
You want to subscribe to all channels starting with 'news.'. Which command is correct?
APSUBSCRIBE news.*
BSUBSCRIBE news.*
CSUBSCRIBE 'news.*'
DPSUBSCRIBE 'news'
Attempts:
2 left
💡 Hint
Pattern subscriptions use a special command starting with P.
🔧 Debug
advanced
1:30remaining
Why does this subscription command fail?
You run SUBSCRIBE without any channel names. What error do you get?
Redis
SUBSCRIBE
A(error) ERR syntax error
B(error) ERR no channels specified
C(error) ERR wrong number of arguments for 'subscribe' command
D(error) ERR unknown command 'SUBSCRIBE'
Attempts:
2 left
💡 Hint
Redis commands require at least one channel name for SUBSCRIBE.
🧠 Conceptual
expert
2:00remaining
What is the behavior of Redis SUBSCRIBE command regarding message delivery?
Which statement correctly describes how Redis delivers messages to subscribers?
AMessages published to a channel are delivered only to clients subscribed to that exact channel.
BMessages published to a channel are delivered to all clients, regardless of subscription.
CMessages published to a channel are delivered only to clients subscribed to matching patterns, not exact channels.
DMessages published to a channel are stored and delivered later when clients subscribe.
Attempts:
2 left
💡 Hint
Think about how pub/sub works in real time.