0
0
Redisquery~10 mins

Time-based event queues in Redis - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add an event with a timestamp to a Redis sorted set.

Redis
ZADD events [1] "event1"
Drag options to blanks, or click blank then click option'
AZADD
B"event1"
Cevents
D1625097600
Attempts:
3 left
💡 Hint
Common Mistakes
Using the event name as the score instead of the timestamp.
Forgetting to provide the score before the member name.
2fill in blank
medium

Complete the code to retrieve all events with timestamps up to a given time.

Redis
ZRANGEBYSCORE events -inf [1]
Drag options to blanks, or click blank then click option'
A"event1"
B1625097600
Cnow
D+inf
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string like 'now' instead of a numeric timestamp.
Using '+inf' which would return all events regardless of time.
3fill in blank
hard

Fix the error in the code to remove events older than a certain timestamp.

Redis
ZREMRANGEBYSCORE events -inf [1]
Drag options to blanks, or click blank then click option'
A1625097600
B"event1"
C+inf
D-inf
Attempts:
3 left
💡 Hint
Common Mistakes
Using a member name instead of a timestamp.
Using '+inf' which would remove all events.
4fill in blank
hard

Fill both blanks to add multiple events with their timestamps to the sorted set.

Redis
ZADD events [1] "event1" [2] "event2"
Drag options to blanks, or click blank then click option'
A1625097600
B"event1"
C1625184000
D"event2"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping event names and timestamps.
Using strings instead of numeric timestamps for scores.
5fill in blank
hard

Fill all three blanks to retrieve events within a time range and limit the number of results.

Redis
ZRANGEBYSCORE events [1] [2] LIMIT 0 [3]
Drag options to blanks, or click blank then click option'
A1625097600
B1625184000
C10
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of timestamps for min and max.
Confusing the LIMIT count with offset.