Introduction
LLEN helps you find out how many items are in a list stored in Redis. It tells you the list's length quickly.
LLEN key
LLEN mylist
LLEN tasks_queue
LLEN emptylist
127.0.0.1:6379> RPUSH mylist "apple" (integer) 1 127.0.0.1:6379> RPUSH mylist "banana" (integer) 2 127.0.0.1:6379> RPUSH mylist "cherry" (integer) 3 127.0.0.1:6379> LLEN mylist (integer) 3 127.0.0.1:6379> LLEN unknownlist (integer) 0
LLEN mylist do?LLEN key.LLEN tasks correctly queries the length of the 'tasks' list.LPUSH fruits apple LPUSH fruits banana LPUSH fruits cherry LLEN fruitsWhat will be the output of
LLEN fruits?LLEN mylist but get an error: "WRONGTYPE Operation against a key holding the wrong kind of value". What is the most likely cause?LLEN orders and check if result >= 5 in your application. -> Option CPass the test and this pattern moves unknown