0
0
Redisquery~20 mins

PSUBSCRIBE for pattern matching in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PSUBSCRIBE Pattern Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What messages does this PSUBSCRIBE receive?
Given the Redis command PSUBSCRIBE news.*, which published messages will the subscriber receive?
Redis
PSUBSCRIBE news.*

PUBLISH news.sports "Sports update"
PUBLISH news.weather "Weather update"
PUBLISH news "General news"
PUBLISH news.sports.football "Football news"
AReceives messages from channels: news only
BReceives messages from channels: news, news.sports, news.weather
CReceives messages from channels: news, news.sports.football
DReceives messages from channels: news.sports, news.weather, news.sports.football
Attempts:
2 left
💡 Hint
Remember that the asterisk (*) matches any characters in the channel name after the prefix.
📝 Syntax
intermediate
1:30remaining
Identify the correct PSUBSCRIBE command syntax
Which of the following Redis commands correctly subscribes to all channels starting with 'chat.'?
APSUBSCRIBE chat.*
BSUBSCRIBE chat.*
CPSUBSCRIBE chat
DSUBSCRIBE chat
Attempts:
2 left
💡 Hint
PSUBSCRIBE supports patterns, SUBSCRIBE does not.
optimization
advanced
2:30remaining
Optimizing pattern subscriptions for multiple similar channels
You want to subscribe to all channels related to user notifications, which are named like 'user.123', 'user.456', 'user.789'. Which PSUBSCRIBE pattern is the most efficient and correct?
APSUBSCRIBE user.?
BPSUBSCRIBE user.*
CPSUBSCRIBE user.[0-9]*
DPSUBSCRIBE user
Attempts:
2 left
💡 Hint
Consider how Redis pattern matching works with wildcards.
🔧 Debug
advanced
2:30remaining
Why does this PSUBSCRIBE pattern not receive expected messages?
A developer runs PSUBSCRIBE user.*.notifications but does not receive messages published to 'user.123notifications'. What is the likely cause?
AThe PSUBSCRIBE command requires escaping dots, so the pattern should be 'user\. *.notifications'.
BRedis patterns treat '*' as matching only one character, so it does not match '123'.
CThe pattern 'user.*.notifications' does not match 'user.123notifications' because Redis patterns do not support multiple wildcards separated by dots.
DThe pattern is correct; the issue is that messages are not published to 'user.123notifications'.
Attempts:
2 left
💡 Hint
Check how Redis pattern matching treats the '*' wildcard.
🧠 Conceptual
expert
3:00remaining
Understanding PSUBSCRIBE pattern matching behavior
Which statement correctly describes how Redis PSUBSCRIBE pattern matching works?
AThe '*' wildcard matches any sequence of characters, including dots, and patterns are matched against the entire channel name.
BThe '*' wildcard matches only characters up to the first dot, so patterns cannot match across dots.
CPatterns in PSUBSCRIBE are matched only against the prefix of channel names, not the entire name.
DPSUBSCRIBE patterns require regular expressions syntax for matching channel names.
Attempts:
2 left
💡 Hint
Think about how the '*' wildcard behaves in Redis channel patterns.