Redis Hash: HGET
Redis HGET Command
Redis HGET command is used to get the value associated with the field in the hash stored at key.
Here are some common uses and scenarios for the "HGET" command:
- Field Value Retrieval: Fetch the value associated with a specific field in a hash.
- Data Access: Access specific data stored in a hash efficiently.
- Configuration Retrieval: Retrieve configuration settings stored as fields within a hash.
- Session Management: Get session data or user attributes stored in a hash.
- Monitoring and Debugging: Inspect the value of specific fields for monitoring or debugging purposes.
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"
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-hget-key-field.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics