Skip to main content

The HSETEX command sets the specified fields with their values and optionally sets their expiration time or TTL. It supports conditional operations to control when fields should be set.

Arguments#

keystringrequired#

The key of the hash.

optionsobject#

Options for conditional setting and expiration.

fields{ [fieldName]: TValue }required#

An object of fields and their values to set.

Response#

numberrequired

1 if all fields were set, 0 if none were set because the conditional check failed (e.g., conditional: "FNX" but a field already exists, or conditional: "FXX" but a field doesn’t exist).

Use Cases#

  • Session Management: Create sessions with automatic expiration
  • Cache with TTL: Store cached data that expires automatically
  • Temporary Data: Create temporary records with built-in cleanup
  • Rate Limiting: Store rate limit counters with automatic reset
  • Conditional Updates: Ensure data consistency with FNX/FXX options