Challenge - 5 Problems
Redis Stream Reader Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What does this XREAD command return?
Given a Redis stream named
What is the output of this command?
mystream with entries:1) 1609459200000-0: {"name":"Alice", "age":"30"}2) 1609459260000-0: {"name":"Bob", "age":"25"}What is the output of this command?
XREAD COUNT 1 STREAMS mystream 0Redis
XREAD COUNT 1 STREAMS mystream 0
Attempts:
2 left
💡 Hint
The COUNT option limits the number of entries returned. The ID '0' means start from the beginning.
✗ Incorrect
The command reads 1 entry from the stream starting at ID '0', so it returns the first entry only.
🧠 Conceptual
intermediate1:30remaining
Understanding the ID parameter in XREAD
In the command
XREAD STREAMS mystream 1609459200000-0, what does the ID 1609459200000-0 specify?Attempts:
2 left
💡 Hint
XREAD reads entries with IDs greater than the given ID.
✗ Incorrect
The ID parameter tells XREAD to return entries with IDs strictly greater than the given ID, so it excludes the entry with that ID.
📝 Syntax
advanced1:30remaining
Identify the syntax error in this XREAD command
Which option contains a syntax error when trying to read from stream
mystream starting at ID 0?Redis
XREAD STREAMS mystream 0Attempts:
2 left
💡 Hint
XREAD requires an ID after the stream name(s).
✗ Incorrect
Option B is missing the ID parameter after the stream name, causing a syntax error.
❓ optimization
advanced2:00remaining
Optimizing XREAD for multiple streams
You want to read new entries from two streams
stream1 and stream2 starting from their latest entries. Which command is the most efficient to do this without reading old entries?Attempts:
2 left
💡 Hint
The special ID '$' means the latest entry in the stream.
✗ Incorrect
Using '$' as the ID tells XREAD to only return new entries added after the command runs, avoiding old entries.
🔧 Debug
expert2:30remaining
Why does this XREAD command block indefinitely?
Consider the command:
Given that
XREAD BLOCK 0 STREAMS mystream 1609459260000-0Given that
mystream has no new entries after ID 1609459260000-0, what is the reason this command blocks indefinitely?Attempts:
2 left
💡 Hint
BLOCK 0 means wait forever until new data arrives.
✗ Incorrect
BLOCK 0 tells XREAD to wait indefinitely for new entries after the specified ID, so if no new entries arrive, it blocks forever.