XINFO STREAM
Introduction
In Dragonfly, as well as in Redis and Valkey, the XINFO STREAM command provides information about a specific stream.
This command can be used to monitor and debug streams, as it helps you understand the structure and state of a stream.
Syntax
XINFO STREAM key [FULL [COUNT count]]
Parameter Explanations
- key: The key of the stream for which information is to be retrieved.
- FULL(optional): If specified, the command returns additional details about the stream.
- COUNT count(optional): If- FULLis specified, this parameter limits the number of returned stream and PEL entries returned.- COUNTis default to- 10. Setting- COUNTto- 0returns all entries, which should be used with caution as it increases execution time for large streams.
Return Values
- The command returns a list of information about the specified stream's state and entries.
Code Examples
Retrieve Stream Information
Get information about a stream:
dragonfly$> XADD mystream * sensor-id 1234 temperature 19.8
"1632494980015-0"
dragonfly$> XINFO STREAM mystream
 1) "length"
 2) (integer) 1
 3) "radix-tree-keys"
 4) (integer) 1
 5) "radix-tree-nodes"
 6) (integer) 2
 7) "groups"
 8) (integer) 0
 9) "last-generated-id"
10) "1632494980015-0"
11) "first-entry"
12) 1) "1632494980015-0"
    2) 1) "sensor-id"
       2) "1234"
       3) "temperature"
       4) "19.8"
13) "last-entry"
14) 1) "1632494980015-0"
    2) 1) "sensor-id"
       2) "1234"
       3) "temperature"
       4) "19.8"
Best Practices
- Regularly use XINFO STREAMto monitor the health and performance of streams.
- Analyze the output to optimize memory and understand stream usage patterns.
Common Mistakes
- Forgetting that XINFO STREAMonly queries data and does not modify the stream content.
- Not grasping the meaning of each output field; ensure you understand terms like radix-tree-keysandlast-generated-idin the context of streams.
FAQs
What does radix-tree-keys signify?
radix-tree-keys indicates the number of entries in the underlying radix tree data structure for streams.
How do I interpret first-entry and `last-entry?
first-entry and last-entry give you the stream's start and end records, which helps to identify the pattern of data.