Challenge - 5 Problems
Stream Capping Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the effect of this XTRIM command?
Given a Redis stream named
mystream with 1000 entries, what will be the number of entries after running this command?XTRIM mystream MAXLEN 100Redis
XTRIM mystream MAXLEN 100Attempts:
2 left
💡 Hint
MAXLEN trims the stream to keep only the newest entries up to the specified count.
✗ Incorrect
XTRIM with MAXLEN 100 keeps only the latest 100 entries by removing older ones.
🧠 Conceptual
intermediate2:00remaining
What does the ~ (approximate) flag do in XTRIM?
Consider the command:
What is the purpose of the
XTRIM mystream MAXLEN ~ 100What is the purpose of the
~ flag in this context?Redis
XTRIM mystream MAXLEN ~ 100Attempts:
2 left
💡 Hint
The ~ flag is used to improve performance by allowing approximate trimming.
✗ Incorrect
Using ~ lets Redis trim close to the specified length but not exactly, improving speed.
📝 Syntax
advanced2:00remaining
Which XTRIM command syntax is correct to cap a stream to 500 entries approximately?
Choose the syntactically correct Redis command to trim
mystream to approximately 500 entries.Attempts:
2 left
💡 Hint
The approximate flag ~ must come immediately after MAXLEN.
✗ Incorrect
The correct syntax places ~ right after MAXLEN followed by the number.
❓ optimization
advanced2:00remaining
Why use approximate trimming (~) instead of exact trimming in XTRIM?
What is the main advantage of using
XTRIM mystream MAXLEN ~ 1000 over XTRIM mystream MAXLEN 1000?Attempts:
2 left
💡 Hint
Think about performance and resource usage when trimming large streams.
✗ Incorrect
Approximate trimming lets Redis trim less frequently and in batches, saving CPU.
🔧 Debug
expert2:00remaining
What error occurs with this XTRIM command?
Given the command:
What will Redis respond?
XTRIM mystream MAXLEN -100What will Redis respond?
Redis
XTRIM mystream MAXLEN -100Attempts:
2 left
💡 Hint
MAXLEN must be a positive number; negative values are invalid.
✗ Incorrect
Redis rejects negative MAXLEN values with an error message.