HLEN · Valkey

HLEN

Returns the number of fields in a hash.

Usage

HLEN key

Description

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

Reply RESP2

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

Reply RESP3

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

Complexity

O(1)

ACL Categories

@fast @hash @read

Examples

127.0.0.1:6379> HSET myhash field1 "Hello"
(integer) 1
127.0.0.1:6379> HSET myhash field2 "World"
(integer) 1
127.0.0.1:6379> HLEN myhash
(integer) 2

History

See also

HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HINCRBYFLOAT, HKEYS, HMGET, HRANDFIELD, HSCAN, HSET, HSETNX, HSTRLEN, HVALS.