Latest web development tutorials

Redis Hlen command

Redis hash (Hash)

Redis Hlen command is used to get the number of fields in the hash table.

grammar

redis Hlen basic command syntax is as follows:

redis 127.0.0.1:6379> HLEN KEY_NAME 

Available versions

> = 2.0.0

return value

The number of fields in the hash table. When the key does not exist, 0 is returned.

Examples

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 hash (Hash)