XLEN
XLEN key
- Group
- Stream
- Complexity
- O(1)
- Arity
- 2 (exactly, counting the command name)
- Flags
- read-only, fast
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
XLEN returns how many entries the stream at key holds. Deleted and trimmed
entries are not counted.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Stream exists | Integer: the number of entries | Integer |
| Key does not exist | Integer 0 |
Integer 0 |
WRONGTYPE if the key holds another type.
Examples
Section titled “Examples”127.0.0.1:6379> XADD sensor 1700000000000-0 temp 21.5"1700000000000-0"127.0.0.1:6379> XADD sensor 1700000000001-0 temp 21.7"1700000000001-0"127.0.0.1:6379> XLEN sensor(integer) 2127.0.0.1:6379> XLEN nosuchstream(integer) 0Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.