Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

HLEN

Last updated
HLEN key
Group
Hash
Complexity
O(1)
Arity
2 (exactly, counting the command name)
Flags
read-only, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

HLEN returns how many fields the hash stored at key holds.

Case RESP2 RESP3
Hash exists Integer: the number of fields Same
Key does not exist Integer 0 Same

HLEN replies with a WRONGTYPE error if key holds a value that is not a hash.

127.0.0.1:6379> HSET user:1 name "Ada" lang "en"
(integer) 2
127.0.0.1:6379> HLEN user:1
(integer) 2
127.0.0.1:6379> HLEN nosuchkey
(integer) 0

Same as Redis 7.4 and Valkey 8.

HKEYS, HVALS, HSTRLEN, HGETALL