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#
The key of the hash.
Options for conditional setting and expiration.
Show propertiesHide properties
Conditional setting options (case-insensitive):
FNX: Only set fields if the hash does not existFXX: Only set fields if the hash already exists
Expiration options for the hash.
Show expirationHide expiration
Set expiration time in seconds.
Set expiration time in milliseconds.
Set expiration as Unix timestamp in seconds.
Set expiration as Unix timestamp in milliseconds.
Retain the existing time to live (TTL) associated with the hash key when setting fields. If the hash has an expiration, it will be preserved. Set to true to enable.
An object of fields and their values to set.
Response#
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