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.
A single field name to set. Use with
value parameter.A single value to set. Use with
field parameter.A dictionary of fields and their values to set. Either use
field/value or values, but not both.Only set fields if the hash does not exist.
Only set fields if the hash already exists.
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.
Response
0 if no fields were set, 1 if all the fields were set.
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