Redis LLEN – How to get a length of the list in redis datastore

5 years ago Lalit Bhagtani 0

In this tutorial, we will learn about how to get the length of a list value stored at the key. For this, we will use Redis LLEN command.

LLEN Command

This command returns the length ( number of elements ) of a list value stored at the key. If a key doesn’t exist in redis datastore, it is interpreted as an empty list and 0 is returned. The syntax of redis LLEN command is as follows :-

Syntax :-

redis host:post> LLEN <key name>

Output :- 

(integer) value, representing the number of elements in the list.
(integer) 0, if key does not exist.
Error, if key exist and value stored at the key is not a list.

Example :-

Redis LLEN

References :-

  1. LLEN Command Docs

That’s all for how to get the length of a list value stored in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.

<- List Commands