Redis - Hash Hlen Command



Redis HLEN command is used to get the number of fields contained in the hash stored at the key.

Return Value

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

Syntax

Following is the basic syntax of Redis HLEN command.

redis 127.0.0.1:6379> HLEN KEY_NAME

Example

redis 127.0.0.1:6379> HSET myhash field1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> HSET myhash field2 "bar" 
(integer) 1 
redis 127.0.0.1:6379> HLEN myhash 
(integer) 2
redis_hashes.htm
Advertisements