Redis HLEN – How to get the number of fields contained in hash value

2 months ago Lalit Bhagtani 0

In this tutorial, we will learn about how to get the number of fields contained in the hash value stored at a key, by using a COMMAND – HLEN in redis-cli. The syntax of redis HLEN command is as follows :-

Syntax :-

redis host:post> HLEN <key name>

Output :- 

- (integer) value, representing the number of fields in the hash.
- 0, if key does not exist.
- Error, if key exist and value stored at the key is not a hash.

Example :-

Redis HLEN

References :-

  1. HLEN Command Docs

That’s all for how to get the number of fields contained in the hash value stored in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.