Redis HVALS Command

The Redis HVALS command returns all values in the hash stored at the specified key.

Syntax

The syntax goes like this:

HVALS key

So all we do is pass the name of the key to the command.

Example

Suppose we set the following hash:

HSET customer firstname "Rob" lastname "Banks" age 37

Result:

(integer) 3

We can use HVALS to get all values from that hash:

HVALS customer

Result:

1) "Rob"
2) "Banks"
3) "37"

The result is an array reply containing the values.

Non-Existent Keys

Running the command against a key that doesn’t exist results in an empty array being returned:

HVALS nonexistentkey

Result:

(empty array)

Passing the Wrong Number of Arguments

Passing the wrong number of arguments results in an error:

HVALS customer lastname

Result:

(error) ERR wrong number of arguments for 'hvals' command