0
0
Redisquery~5 mins

PSUBSCRIBE for pattern matching in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command PSUBSCRIBE do?

PSUBSCRIBE lets you listen to messages on channels that match a pattern. Instead of subscribing to one channel, you subscribe to many channels that fit the pattern.

Click to reveal answer
beginner
How does pattern matching work in PSUBSCRIBE?

Patterns can include * as a wildcard to match any characters. For example, news.* matches all channels starting with news..

Click to reveal answer
beginner
What is the difference between SUBSCRIBE and PSUBSCRIBE?

SUBSCRIBE listens to exact channel names. PSUBSCRIBE listens to channels matching a pattern, allowing multiple channels with one command.

Click to reveal answer
beginner
Can you receive messages from multiple channels using one PSUBSCRIBE command?

Yes! PSUBSCRIBE lets you listen to many channels at once if their names match the pattern you provide.

Click to reveal answer
intermediate
What kind of message does Redis send when you use PSUBSCRIBE?

Redis sends a message confirming the subscription and then sends messages from any channel matching the pattern as they arrive.

Click to reveal answer
What symbol is used as a wildcard in Redis PSUBSCRIBE patterns?
A%
B*
C#
D?
Which command subscribes to channels matching a pattern?
APSUBSCRIBE
BSUBSCRIBE
CPUBLISH
DUNSUBSCRIBE
If you want to listen to all channels starting with 'chat.', which command would you use?
APSUBSCRIBE chat
BSUBSCRIBE chat.*
CSUBSCRIBE chat
DPSUBSCRIBE chat.*
What happens if a message is published to a channel matching your PSUBSCRIBE pattern?
ARedis unsubscribes you
BThe message is ignored
CYou receive the message
DYou get an error
Can PSUBSCRIBE listen to multiple patterns at once?
AYes, by listing multiple patterns
BNo, only one pattern at a time
COnly if patterns are separated by commas
DOnly with a special flag
Explain how PSUBSCRIBE works in Redis and how it differs from SUBSCRIBE.
Think about subscribing to many channels with one pattern.
You got /4 concepts.
    Describe a real-life example where using PSUBSCRIBE would be helpful.
    Imagine you want to get updates from all chat rooms starting with 'room1.'
    You got /3 concepts.