XINFO command is used to retrieve information and statistics about a stream. You can use it to get detailed statistics for troubleshooting, monitoring, or optimizing the streams in your application.
Here are a couple of examples using
XINFO with redis-py (a Python client for Redis).
Assume that you have a stream called "mystream".
In this snippet, we first establish a connection to the Redis server. Then, we call the
xinfo_stream method on the stream 'mystream'. This will return a Python dictionary filled with information about the stream.
You can also fetch information about consumers and groups related to a particular stream:
In this example,
xinfo_groups returns information about consumer groups associated with 'mystream', while
xinfo_consumers gives details about consumers within a specific group ('mygroup' in this case).
XINFOsparingly in production environments. Although it's a very useful command for debugging and understanding your data, it does add some overhead to your Redis instance.
XINFO, as attempting to retrieve information on a non-existent stream will result in an error.
XINFOon data types other than streams -
XINFOis specifically designed for use with Redis Streams, using it on different data types will result in an error.
Q: Can I use
XINFO to find information about keys or values in Redis?
XINFO is specifically designed for use with Redis Streams. For keys, you may want to look into the
KEYS command and for values your choice of command depends on the specific type of value stored.