Which of the following best explains why Redis Streams are a good choice for handling event logs?
Think about how event logs need to keep events in order and allow new events to be added efficiently.
Redis Streams keep events in an ordered, append-only structure which is perfect for event logs. They allow efficient reading and trimming, making them ideal for this use case.
What is the output of the following Redis command sequence?
XADD mystream * event "login" user "alice" XADD mystream * event "logout" user "bob" XRANGE mystream - +
Redis assigns incremental IDs starting from 1-0 if you use * for the ID.
Using * in XADD generates IDs like 1-0, 2-0, etc. XRANGE returns all entries in order.
Which option contains a syntax error when adding an event to a Redis Stream?
XADD mystream * event login user alice
Check how field-value pairs should be formatted in XADD.
Redis expects field and value as separate arguments. Option D misses quotes around values, causing a syntax error.
Which Redis command option is best to limit the size of a stream to avoid unbounded growth when handling event logs?
Consider approximate trimming to improve performance.
Using MAXLEN ~ 1000 trims the stream approximately to 1000 entries, which is efficient and prevents unbounded growth.
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
Think about how XREAD uses IDs to read new events and how blocking works.
ID '0' means read from the very start, but if the consumer blocks waiting for events after '0' and no new events are added, it will wait indefinitely.