w3resource

Redis Hash: HLEN

HLEN key

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

Syntax:

HLEN KEY_NAME  

Available since

2.0.0.

Return Value

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

Return Value Type

Integer

Example: HLEN

127.0.0.1:6379> HSET langhash lang1 "PHP"
(integer) 1
127.0.0.1:6379> HSET langhash lang2 "Javascript"
(integer) 1
127.0.0.1:6379> HSET langhash lang3 "Python"
(integer) 1
127.0.0.1:6379> HSET langhash lang4 "Golanguage"
(integer) 1
127.0.0.1:6379> HLEN langhash
(integer) 4

Example: Redis HLEN another example

127.0.0.1:6379> HMSET user-x name Sweaty gender Female lang English
OK
127.0.0.1:6379> HLEN user-x
(integer) 3

Previous: HKEYS
Next: HMGET



Follow us on Facebook and Twitter for latest update.