Hash
HPEXPIREAT
Sets an expiration time for field(s) in a hash in milliseconds since the Unix epoch.
Arguments
keybodystringrequired
The key of the hash.
fieldsbodystring | number | (string | number)[]required
The field(s) to set an expiration time for.
timestampbodynumberrequired
The expiration time as a Unix timestamp in milliseconds.
optionbodystring
Optional condition for setting the expiration:
NX: Set the expiration only if the field does not already have an expiration.XX: Set the expiration only if the field already has an expiration.GT: Set the expiration only if the new TTL is greater than the current TTL.LT: Set the expiration only if the new TTL is less than the current TTL.
Response
number[]required
A list of integers indicating whether the expiry was successfully set.
-2if the field does not exist in the hash or if key doesn't exist.0if the expiration was not set due to the condition.1if the expiration was successfully set.2if called with 0 seconds/milliseconds or a past Unix time.
For more details, see HPEXPIREAT documentation.
Example
await redis.hset("my-key", "my-field", "my-value");const expirationSet = await redis.hpexpireat("my-key", "my-field", Date.now() + 1000);console.log(expirationSet); // [1]