HLEN key

Available since 2.0.0.

Time complexity: O(1)

Returns the number of fields contained in the hash stored at key.

*Return value

Integer reply: number of fields in the hash, or 0 when key does not exist.

*Examples

redis> HSET myhash field1 "Hello"

  1. (integer) 1

redis> HSET myhash field2 "World"

  1. (integer) 1

redis> HLEN myhash

  1. (integer) 2
redis>