Redis - List Llen Command



Redis LLEN command returns the length of the list stored at the key. If the key does not exist, it is interpreted as an empty list and 0 is returned. An error is returned when the value stored at the key is not a list.

Return Value

Integer reply, the length of the list at the key.

Syntax

Following is the basic syntax of Redis LLEN command.

redis 127.0.0.1:6379> LLEN KEY_NAME

Example

redis 127.0.0.1:6379> RPUSH list1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> RPUSH list1 "bar" 
(integer) 2 
redis 127.0.0.1:6379> LLEN list1 
(integer) 2
redis_lists.htm
Advertisements