Redis Hash: HEXISTS
Redis HEXISTS Command
Redis HEXISTS command is used to check whether a hash field stored at key or not.
Here are some common uses and scenarios for the "HEXISTS" command:
- Field Presence Check: Verify the existence of a specific field in a hash.
- Conditional Logic: Execute operations based on the presence of fields within a hash.
- Data Validation: Ensure required fields are present before processing.
- Debugging and Monitoring: Check if fields exist for debugging or monitoring purposes.
- Configuration Management: Validate the existence of specific configuration settings stored in a hash.
Syntax:
HEXISTS KEY_NAME FIELD_NAME
Available since
2.0.0.
Return Value
Integer reply, 1 or 0.
Return Value Type
Integer
- 1, if the hash contains a field.
- 0 if the hash does not contain a field, or key does not exist.
Example: Redis HEXISTS
127.0.0.1:6379> HMSET langhash lang1 "PHP" lang2 "JavaScript" lang3 "Python" OK 127.0.0.1:6379> HEXISTS langhash lang1 (integer) 1 127.0.0.1:6379> HEXISTS langhash lang4 (integer) 0
Example: Redis HEXISTS another example
127.0.0.1:6379> HSET user email [email protected] (integer) 1 127.0.0.1:6379> HEXISTS user email (integer) 1 127.0.0.1:6379> HEXISTS user xyz (integer) 0
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-hexists-key-field.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics