0
0
Redisquery~20 mins

Time-based event queues in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Time-based Event Queue Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Retrieve events scheduled before a specific timestamp
Given a Redis sorted set named events where the score is the event timestamp, which command returns all events scheduled before timestamp 1650000000?
AZRANGEBYSCORE events -inf 1650000000
BZRANGEBYSCORE events 1650000000 +inf
CZRANGE events 0 1650000000
DZREVRANGEBYSCORE events 1650000000 -inf
Attempts:
2 left
💡 Hint
Remember that scores in sorted sets represent timestamps and you want all events with scores less than or equal to 1650000000.
📝 Syntax
intermediate
1:30remaining
Identify the correct syntax to add a timed event
Which Redis command correctly adds an event named event42 scheduled at timestamp 1680000000 to a sorted set events?
AZADD events 1680000000 event42
BZADD events event42 1680000000
CZADD events (1680000000) event42
DZADD events event42
Attempts:
2 left
💡 Hint
ZADD syntax requires the score first, then the member.
optimization
advanced
2:00remaining
Efficiently removing expired events
You want to remove all events from the events sorted set that have timestamps less than the current time 1690000000. Which command is the most efficient to do this?
AZREM events 1690000000
BZREMRANGEBYSCORE events -inf (1690000000
CZREM events -inf 1690000000
DZREMRANGEBYRANK events 0 1690000000
Attempts:
2 left
💡 Hint
Removing by score range is best for timestamp-based removals.
🔧 Debug
advanced
2:00remaining
Why does this time-based event retrieval return no results?
A developer runs this command to get events before timestamp 1700000000: ZRANGEBYSCORE events (1700000000 -inf. Why does it return no results?
AThe command syntax is correct; the sorted set is empty
BParentheses around 1700000000 exclude that score, causing no matches
CThe score range is reversed; min should be less than max
DZRANGEBYSCORE does not support negative infinity
Attempts:
2 left
💡 Hint
Check the order of min and max arguments in ZRANGEBYSCORE.
🧠 Conceptual
expert
2:30remaining
Choosing the best data structure for time-based event queues
Which Redis data structure is best suited for implementing a time-based event queue where events must be processed in order of their scheduled timestamps?
AList because it maintains insertion order and supports push/pop operations
BSet because it stores unique members without order
CHash because it stores key-value pairs for fast lookup
DSorted Set (ZSET) because it stores members with scores and supports range queries by score
Attempts:
2 left
💡 Hint
Consider which structure supports ordering by timestamp and efficient range queries.