Challenge - 5 Problems
Redis Stream Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of XREADGROUP with new consumer
Given a Redis stream 'mystream' with entries and a consumer group 'mygroup', what will be the output of this command?
XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream >
Redis
XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream >Attempts:
2 left
💡 Hint
The '>' ID in XREADGROUP returns only new messages never delivered to any consumer in the group.
✗ Incorrect
Using '>' as the ID in XREADGROUP returns messages that have never been delivered to any consumer in the group. Since the stream has entries, the first two new entries will be returned.
🧠 Conceptual
intermediate2:00remaining
Behavior of XREADGROUP with ID '0'
What happens when you run the following command for a consumer group that already exists?
XREADGROUP GROUP mygroup consumer2 STREAMS mystream 0
Attempts:
2 left
💡 Hint
Using '0' as the ID in XREADGROUP means to read from the beginning of the stream.
✗ Incorrect
When using '0' as the ID, XREADGROUP returns all messages in the stream, regardless of delivery status, which can cause duplicates if messages were already delivered.
📝 Syntax
advanced2:00remaining
Identify the syntax error in XREADGROUP command
Which of the following XREADGROUP commands has a syntax error?
Attempts:
2 left
💡 Hint
The COUNT option must appear before STREAMS and stream keys.
✗ Incorrect
In option A, COUNT 5 appears after STREAMS and stream keys, which is invalid syntax. COUNT must come before STREAMS.
❓ optimization
advanced2:00remaining
Optimizing XREADGROUP for multiple streams
You want to read new messages from two streams 'stream1' and 'stream2' for consumer 'c1' in group 'g1'. Which command efficiently reads only new messages from both streams?
Attempts:
2 left
💡 Hint
Use '>' to read only new messages never delivered to any consumer in the group.
✗ Incorrect
Using '>' for each stream ID reads only new messages never delivered to any consumer. Adding COUNT limits the number of messages returned, optimizing performance.
🔧 Debug
expert2:00remaining
Why does XREADGROUP return no messages?
A consumer group 'g1' exists on stream 'mystream'. Consumer 'c1' runs:
But it returns an empty array even though the stream has new messages. What is the most likely cause?
XREADGROUP GROUP g1 c1 STREAMS mystream > COUNT 5
But it returns an empty array even though the stream has new messages. What is the most likely cause?
Attempts:
2 left
💡 Hint
The group ID determines which messages are considered new for '>' reads.
✗ Incorrect
If the group was created with an ID greater than the IDs of new messages, '>' will not return those messages because they are considered older than the group's last delivered ID.