Redis Lists: LLEN
Redis LLEN Command
Redis LLEN command returns the length of the list stored at key. If a key does not exist, it is interpreted as an empty list and 0 is returned. An error is returned when the value stored at key is not a list.
Here are some common uses and scenarios for the "LLEN" command:
- Size Retrieval: Determine the number of elements in a list.
- Data Validation: Validate list size for consistency and correctness.
- Capacity Monitoring: Monitor the length of lists to manage capacity and performance.
- Conditional Logic: Execute operations based on the length of a list.
- Resource Management: Manage resources by tracking the size of lists for optimization.
Syntax:
LLEN KEY_NAME
Available since
1.0.0.
Return Value
Integer replies the length of the list at a key.
Return Value Type
Integer
Example: Redis LLEN
127.0.0.1:6379> LPUSH mycolor1 white black red blue (integer) 4 127.0.0.1:6379> LRANGE mycolor1 0 -1 1) "blue" 2) "red" 3) "black" 4) "white" 127.0.0.1:6379> LLEN mycolor1 (integer) 4
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-llen-key.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics