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
The key of the hash.
Options for conditional setting and expiration.
An object of fields and their values to set.
Response
The number of fields that were set. Returns 0 if conditions are not met (e.g.,
conditional: "FNX" but hash exists, or conditional: "FXX" but hash 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