Skip to main content

Usage

Returns the values associated with the specified fields in the hash stored at key. Returns an object with the requested fields.

Parameters

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

Response

object
TData | null
An object containing the requested fields and their values. Fields that do not exist will have null values.Returns null if the hash does not exist or all requested fields are empty.The return type is a record where keys are the requested field names and values are the stored values (or null if the field doesn’t exist).

Examples

Get multiple fields

Handle missing fields

Working with typed data

Fetch subset of large hash

Non-existent hash

All fields are null

Efficient partial reads

Build partial objects

Batch read from multiple hashes

Check field values efficiently

Notes

  • More efficient than multiple HGET calls when you need multiple fields
  • More efficient than HGETALL when you only need a subset of fields
  • Returns null for the entire result if the hash doesn’t exist or all fields are null
  • Individual fields that don’t exist have null values in the returned object
  • Values are automatically parsed from JSON when possible

See Also

  • HGET - Get a single hash field value
  • HGETALL - Get all fields and values in a hash
  • HSET - Set hash field values
  • HMSET - Set multiple hash fields