Redis HKEYS – How to get names of all the fields contained in hash value

5 years ago Lalit Bhagtani 0

In this tutorial, we will learn about how to get the names of all fields contained in the hash value stored at a key, by using a COMMAND – HKEYS in redis-cli.

Empty list is returned, if key does not exist and error is returned, if key exist but value stored at the key is not of hash datatype. The syntax of redis HKEYS command is as follows :-

Syntax :-

redis host:post> HKEYS <keyname>

Output :- 

- (array) reply, representing the list of fields in the hash.
- Empty list, if key does not exist.
- Error, if key exist and value stored at the key is not a hash.

Example :-

Redis HKEYS

References :-

  1. HKEYS Command Docs

That’s all for how to get the names of all 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.