0
0
Redisquery~20 mins

Why streams handle event logs in Redis - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Stream Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why are Redis Streams suitable for event logs?

Which of the following best explains why Redis Streams are a good choice for handling event logs?

ABecause Redis Streams automatically delete old events without any configuration.
BBecause Redis Streams store data in a relational table format for easy querying.
CBecause Redis Streams store events in an ordered, append-only log that supports efficient reading and trimming.
DBecause Redis Streams require manual indexing of each event to maintain order.
Attempts:
2 left
💡 Hint

Think about how event logs need to keep events in order and allow new events to be added efficiently.

query_result
intermediate
2:00remaining
Output of adding events to a Redis Stream

What is the output of the following Redis command sequence?

XADD mystream * event "login" user "alice"
XADD mystream * event "logout" user "bob"
XRANGE mystream - +
A[["1-0", {"event": "login", "user": "alice"}], ["2-0", {"event": "logout", "user": "bob"}]]
BSyntaxError: XRANGE requires a stream key
C[["1609459200000-0", {"event": "login", "user": "alice"}], ["1609459200001-0", {"event": "logout", "user": "bob"}]]
D[]
Attempts:
2 left
💡 Hint

Redis assigns incremental IDs starting from 1-0 if you use * for the ID.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in Redis Stream command

Which option contains a syntax error when adding an event to a Redis Stream?

XADD mystream * event login user alice
AXADD mystream * event:login user:alice
BXADD mystream * event "login" user "alice"
CXADD mystream * event='login' user='alice'
DXADD mystream * event login user alice
Attempts:
2 left
💡 Hint

Check how field-value pairs should be formatted in XADD.

optimization
advanced
2:00remaining
Best practice to limit Redis Stream size for event logs

Which Redis command option is best to limit the size of a stream to avoid unbounded growth when handling event logs?

AXADD mystream MINLEN 1000 * event "click" user "john"
BXADD mystream MAXLEN ~ 1000 * event "click" user "john"
CXADD mystream MAXLEN 1000 * event "click" user "john"
DXADD mystream TRIMLEN 1000 * event "click" user "john"
Attempts:
2 left
💡 Hint

Consider approximate trimming to improve performance.

🔧 Debug
expert
2:00remaining
Why does this Redis Stream consumer fail to read new events?

A consumer uses XREAD with the ID '0' to read new events from a stream but never receives any new data. Why?

XREAD BLOCK 0 STREAMS mystream 0
ABecause ID '0' reads from the beginning and blocks until new events after '0' arrive, but no new events are added.
BBecause the BLOCK 0 option causes an immediate timeout, so no data is returned.
CBecause the stream key 'mystream' does not exist, so XREAD fails silently.
DBecause the ID '0' is invalid and causes a syntax error.
Attempts:
2 left
💡 Hint

Think about how XREAD uses IDs to read new events and how blocking works.