STRLEN(3valkey)

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

πŸ’… STRLEN β€” the Valkey string-length bestie

ok so real talk, this page is STRLEN(3valkey) from the Valkey Command Manual, and it's about to become your new fave lil one-liner. no cap.


✨ NAME ✨

strlen β€” Returns the length of a string value.

like. it counts the letters. that's the whole job. and it does it flawlessly.


πŸŽ€ SYNOPSIS πŸŽ€

STRLEN key

one argument. one key. we love a low-maintenance icon 🫢


🌸 DESCRIPTION 🌸

Returns the length of the string value stored at key. periodt.

An error is returned when key holds a non-string value. so if you try to get the length of, say, a list, bestie... no. error. it's giving "wrong department". 😭


πŸ’– REPLY πŸ’–

valkey-protocol(7) Integer reply: the length of the string stored at key, or 0 when the key does not exist.

yes you read that right β€” a key that doesn't exist isn't an error, it's just a 0. she's chill like that. zero drama, literally. ✨


⚑ COMPLEXITY ⚑

O(1)

constant time. instant. iconic. no scanning, no searching, she just knows. πŸ’…


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @fast
  • @read
  • @string

three categories, all of them slaying.


πŸ¦‹ HISTORY πŸ¦‹

  • Available since: 2.2.0

so she's been around since 2.2.0 β€” old money, honestly. a legacy.


🌈 EXAMPLES 🌈

127.0.0.1:6379> SET mykey "Hello world"
OK
127.0.0.1:6379> STRLEN mykey
(integer) 11
127.0.0.1:6379> STRLEN nonexisting
(integer) 0

see how "Hello world" is 11 characters? (yes, the space counts, the space ALWAYS counts 🫢) and nonexisting? boom, (integer) 0. no error, no tantrum, just a calm little zero. we stan a stable queen.


⭐ SEE ALSO ⭐

the whole friend group, go say hi:


quick vibe check: if key is holding something that isn't a string, STRLEN throws an error. not every data type gets to be measured. that's just the rules, bestie. πŸ™ˆ

ok that's the whole page!! this was STRLEN(3valkey), version 9.0.0, dated 2025-10-21. go measure something. length-queen behaviour only. mwah πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from