Skip to main content

Usage

Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored.

Parameters

key
string
required
The key of the hash
fields
string[]
required
One or more field names to delete from the hash

Response

count
0 | 1
Returns 1 if at least one field was removed, 0 if no fields were removed (either because they didn’t exist or the key doesn’t exist).

Examples

Delete a single field

Delete multiple fields

Delete non-existent field

Delete from non-existent key

Remove sensitive data

Clean up cache fields

Notes

  • If the key does not exist, it is treated as an empty hash and the command returns 0
  • The return value indicates whether any field was removed, not the count of removed fields
  • If all fields are removed, the key itself will be automatically deleted

See Also

  • HSET - Set hash field values
  • HEXISTS - Check if a hash field exists
  • HGET - Get a hash field value