Challenge - 5 Problems
Redis Stream Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What does this XADD command return?
Consider the Redis command:
What is the output of this command?
XADD mystream * sensor-id 1234 temperature 19.8What is the output of this command?
Redis
XADD mystream * sensor-id 1234 temperature 19.8
Attempts:
2 left
💡 Hint
XADD returns the ID of the new entry added to the stream.
✗ Incorrect
The XADD command adds an entry to the stream and returns the entry's ID, which is a string with a timestamp and sequence number.
📝 Syntax
intermediate2:00remaining
Which XADD command is syntactically correct?
Choose the syntactically valid Redis XADD command to add an entry with fields 'user'='alice' and 'score'='42' to stream 'game_scores'.
Attempts:
2 left
💡 Hint
The * must come immediately after the stream name, followed by field-value pairs without extra symbols.
✗ Incorrect
The correct syntax is: XADD [ ...]. Option A follows this exactly.
❓ optimization
advanced2:00remaining
How to limit stream length efficiently with XADD?
You want to add entries to a Redis stream 'logs' but keep only the latest 1000 entries to save memory. Which XADD option achieves this efficiently?
Attempts:
2 left
💡 Hint
Using ~ after MAXLEN allows approximate trimming which is faster.
✗ Incorrect
Option B uses 'MAXLEN ~ 1000' which trims the stream approximately to 1000 entries, improving performance over exact trimming.
🔧 Debug
advanced2:00remaining
Why does this XADD command cause an error?
Given the command:
Why might this cause an error?
XADD mystream 1657891234567-0 sensor 12Why might this cause an error?
Redis
XADD mystream 1657891234567-0 sensor 12
Attempts:
2 left
💡 Hint
Manually specifying an ID that already exists causes an error.
✗ Incorrect
XADD with a manual ID fails if that ID already exists in the stream, causing a duplicate ID error.
🧠 Conceptual
expert2:00remaining
What is the purpose of the '*' ID in XADD?
In Redis Streams, what does using '*' as the ID in the XADD command do?
Attempts:
2 left
💡 Hint
The * is a special placeholder for IDs in Redis Streams.
✗ Incorrect
Using '*' lets Redis create a unique ID automatically, combining the current time and a sequence number to avoid collisions.