0
0
Redisquery~5 mins

XREAD for reading entries in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command XREAD do?
The XREAD command reads new entries from one or more Redis streams. It returns stream entries starting from a given ID.
Click to reveal answer
beginner
How do you specify which streams to read from using XREAD?
You provide the XREAD command with the keyword STREAMS, followed by the stream names and the IDs from which to start reading.
Click to reveal answer
intermediate
What does the ID $ mean when used with XREAD?
The ID $ means to read only new entries added after the command is called, ignoring existing entries.
Click to reveal answer
intermediate
What happens if you use XREAD BLOCK 0?
The command will block (wait) indefinitely until a new entry arrives in the stream, then return it.
Click to reveal answer
advanced
How can you read from multiple streams at once using XREAD?
You list multiple stream names after STREAMS and provide one ID per stream. XREAD returns entries from all those streams starting from the given IDs.
Click to reveal answer
What does XREAD STREAMS mystream 0 do?
ABlocks forever without returning any entries.
BReads only new entries added after the command runs.
CDeletes all entries from 'mystream'.
DReads all entries from 'mystream' starting from the very first entry.
Which ID should you use with XREAD to get only new entries added after the command runs?
A0
B$
C-
D*
What does the BLOCK option do in XREAD?
ADeletes entries after reading.
BLimits the number of entries returned.
CWaits for new entries if none are available.
DReads entries in reverse order.
How do you read from two streams named 's1' and 's2' starting from their latest entries?
AXREAD STREAMS s1 s2 $ $
BXREAD STREAMS s1 s2 0 0
CXREAD STREAMS s1 s2 * *
DXREAD STREAMS s1 s2 - -
What is the output format of XREAD?
AA list of entries with stream name, entry ID, and fields.
BA boolean indicating success.
CA count of entries read.
DA list of stream names only.
Explain how to use XREAD to read new entries from a Redis stream named 'orders'.
Think about reading only new data and waiting for it.
You got /4 concepts.
    Describe the difference between using ID '0' and '$' with XREAD.
    Consider what entries exist before and after the command.
    You got /3 concepts.