STRLEN(3valkey)
π 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 β‘
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:
append(3valkey)decr(3valkey)decrby(3valkey)delifeq(3valkey)get(3valkey)getdel(3valkey)getex(3valkey)getrange(3valkey)getset(3valkey)incr(3valkey)incrby(3valkey)incrbyfloat(3valkey)lcs(3valkey)mget(3valkey)mset(3valkey)msetnx(3valkey)psetex(3valkey)set(3valkey)setex(3valkey)setnx(3valkey)setrange(3valkey)substr(3valkey)
quick vibe check: ifkeyis holding something that isn't a string,STRLENthrows 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
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms