w3resource

Redis Hash: HGET

HGET key field

Redis HGET command is used to get the value associated with the field in the hash stored at key.

Syntax:

HGET KEY_NAME FIELD_NAME

Available since

2.0.0.

Return Value

String reply, the value associated with the field, or nil when the field is not present in the hash or key does not exist.

Return Value Type

Integer

Example: Redis HGET

127.0.0.1:6379> HMSET langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python"
OK
127.0.0.1:6379> HGET langhash lang1
"PHP"
127.0.0.1:6379> HGET langhash lang4
(nil)

Example: Redis HGET another example

127.0.0.1:6379> HGETALL user
1) "email"
2) "[email protected]"
3) "lang"
4) "English"
5) "gender"
6) "Male"
127.0.0.1:6379> HGET user email
"[email protected]"
127.0.0.1:6379> HGET user lang
"English"

Previous: HEXISTS
Next: HGETALL



Follow us on Facebook and Twitter for latest update.