Skip to main content

Usage

Returns if field is an existing field in the hash stored at key.

Parameters

key
string
required
The key of the hash
field
string
required
The field name to check for existence

Response

exists
number
Returns 1 if the hash contains the field, 0 if the hash does not contain the field or the key does not exist.

Examples

Check if a field exists

Conditional field operations

Validate required fields

Check before deletion

Feature flag checking

Non-existent key

Notes

  • Returns 1 (not true) when the field exists
  • Returns 0 (not false) when the field doesn’t exist
  • Useful for conditional logic before setting or deleting fields
  • More efficient than getting the value when you only need to check existence

See Also

  • HGET - Get a hash field value
  • HSET - Set hash field values
  • HDEL - Delete hash fields
  • HKEYS - Get all field names in a hash