HSTRLEN(3valkey)

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

✨ HSTRLEN πŸ’…

okay bestie so this is a page from the Valkey Command Manual, section 3valkey β€” yes the whole thing lives in the manual, and today we're learning about hstrlen. it's giving "how long is this field's value actually" energy and honestly? iconic.


πŸŽ€ NAME πŸŽ€

hstrlen β€” Returns the length of the value of a field. that's it. that's the whole job. no cap.


🌸 SYNOPSIS 🌸

HSTRLEN key field

just two little arguments, two little besties, one very chill command 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: HSTRLEN returns the string length of the value that's associated with field inside the hash stored at key. that's the vibe.

and if the key doesn't exist, or the field doesn't exist? you get 0. zero. nothing. empty. the void returns a number and the number is zero πŸ’€


πŸ’– REPLY πŸ’–

valkey-protocol(7) Integer reply β€” literally just the string length of the value associated with the field, or zero when the field isn't present in the hash or the key doesn't exist at all. both of those sad little scenarios give you 0. periodt.


⭐ COMPLEXITY ⭐

O(1)

constant time bestie, it does not care how big your hash is, it is NOT stressing ✨


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @fast
  • @hash
  • @read

three little tags, all of them slay 🌈


🌸 HISTORY 🌸

  • Available since: 3.2.0 β€” a classic, honestly. vintage but make it fast 🧚

πŸ”₯ EXAMPLES πŸ”₯

watch this, it's so satisfying:

127.0.0.1:6379> HSET myhash f1 HelloWorld f2 99 f3 -256
(integer) 3
127.0.0.1:6379> HSTRLEN myhash f1
(integer) 10
127.0.0.1:6379> HSTRLEN myhash f2
(integer) 2
127.0.0.1:6379> HSTRLEN myhash f3
(integer) 4

ok so HelloWorld is 10 characters, 99 is 2, and -256 is 4 β€” because the minus sign is a character too, bestie. the way it counts the - as a whole entire character… not me being obsessed with string semantics πŸ™ˆ


πŸŽ€ SEE ALSO πŸŽ€

the whole hash girlie squad, go read them too:


lowkey a reminder: HSTRLEN only cares about the length of the string value. it doesn't care if the value looks like a number, it's still a string and it's still getting counted. iykyk πŸ’…

okay that's the whole page bestie, we ate and left no crumbs πŸ’– this one's from version 9.0.0, dated 2025-10-21, and that's the HSTRLEN(3valkey) manual page β€” go forth and count your strings, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from