LLEN(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

✨ LLEN ✨

okay bestie, this is the llen page from the valkey command manual (manual name valkey, section 3 β€” we stan a classic) and it's literally the easiest thing you'll read all day πŸ’–


πŸ¦‹ NAME πŸ¦‹

llen β€” returns the length of a list. that's it. that's the whole job. and she does it flawlessly πŸ‘‘


🌸 SYNOPSIS 🌸

LLEN key

one argument. one. we love a low-maintenance icon πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea: LLEN hands you back the length of the list stored at key.

but wait, there's a plot twist for the nonexistent-key girlies: if key does not exist, it gets interpreted as an empty list, and you get 0 back. no drama, no error, just a chill little zero 🫢

and now the *un*chill part β€” if the value stored at key is not a list, you get an error. so if you're out here running LLEN on a string, bestie, that's not it 😭 she will not be nice about it.


🌈 REPLY 🌈

valkey-protocol(7) Integer reply: the length of the list. just a whole number, sparkling and correct ⭐


πŸŽ€ COMPLEXITY πŸŽ€

O(1)

constant time!! instant!! no scanning, no searching, she already knows. main character speed fr fr πŸ”₯


πŸ’… ACL CATEGORIES πŸ’…

@fast @list @read

so: she's fast, she's a list girl, and she's read-only. a whole vibe check passed with flying colors βœ…


🧚 HISTORY 🧚

  • Available since: 1.0.0

she's been here since day one. a true original. an elder stateswoman. respect her πŸ‘‘


πŸ“ EXAMPLES πŸ“

look how cute this is:

127.0.0.1:6379> LPUSH mylist "World"
(integer) 1
127.0.0.1:6379> LPUSH mylist "Hello"
(integer) 2
127.0.0.1:6379> LLEN mylist
(integer) 2

see how that works?? you push "World" in, you got 1. you push "Hello" in, you got 2. then LLEN mylist says 2. she counted. she always counts. obsessed 😌


πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, bestie, the whole list squad is here:


heads up bestie: if key holds something that is not a list, LLEN returns an error. don't shoot the messenger πŸ’€

and that's the page!! version 9.0.0, dated 2025-10-21 β€” go count some lists, you absolute legend πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from