hlen.3valkey - Man Page

Returns the number of fields in a hash.

Synopsis

HLEN key

Description

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

Reply

Resp2

valkey-protocol(7) Integer reply: the number of fields in the hash, or 0 when the key does not exist.

Resp3

valkey-protocol(7) 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

History

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

See Also

hdel(3valkey), hexists(3valkey), hget(3valkey), hgetall(3valkey), hincrby(3valkey), hincrbyfloat(3valkey), hkeys(3valkey), hmget(3valkey), hrandfield(3valkey), hscan(3valkey), hset(3valkey), hsetnx(3valkey), hstrlen(3valkey), hvals(3valkey)

Info

2024-09-23 8.0.0 Valkey Command Manual