0
0
Redisquery~5 mins

XADD for adding entries in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command XADD do?

XADD adds a new entry to a Redis stream. It appends data with a unique ID to the stream.

Click to reveal answer
beginner
What is the purpose of the * symbol in XADD mystream *?

The * tells Redis to auto-generate a unique ID for the new stream entry based on the current time.

Click to reveal answer
beginner
How do you specify the fields and values when using XADD?

After the stream name and ID, you list pairs of field names and their values, like field1 value1 field2 value2.

Click to reveal answer
intermediate
What happens if you use XADD mystream 12345-0 field1 value1 and the ID already exists?

Redis will return an error because stream entry IDs must be unique and cannot be reused.

Click to reveal answer
intermediate
How can you limit the length of a Redis stream when adding entries with XADD?

You can use the MAXLEN option to trim the stream to a certain length, for example: XADD mystream MAXLEN 1000 * field value.

Click to reveal answer
What does the XADD command do in Redis?
AAdds a new entry to a stream
BDeletes a stream
CReads entries from a stream
DCreates a new database
In XADD mystream *, what does the asterisk * mean?
AAuto-generate an entry ID
BDelete all entries
CAdd multiple entries
DUse a fixed ID
Which of these is a valid way to add fields with XADD?
AXADD mystream * field1 field2 value1 value2
BXADD mystream * value1 field1 value2 field2
CXADD mystream *
DXADD mystream * field1 value1 field2 value2
What happens if you try to add an entry with an existing ID using XADD?
AEntry is overwritten
BRedis returns an error
CEntry is ignored
DStream is deleted
How do you limit the length of a stream when adding entries?
AUse <code>TRIM</code> command separately
BUse <code>LIMIT</code> option
CUse <code>MAXLEN</code> option
DUse <code>DELETE</code> command
Explain how to add a new entry to a Redis stream using XADD.
Think about the order of arguments and how Redis generates IDs.
You got /3 concepts.
    Describe how to keep a Redis stream from growing too large when adding entries.
    Consider how to limit stream size during XADD.
    You got /3 concepts.