Redis Expireat Command
The Redis Expireat command is used to set the expiration time for a key in UNIX timestamp format. Once the key expires, it will no longer be available.
Syntax
The basic syntax for the redis Expireat command is as follows:
redis 127.0.0.1:6379> EXPIREAT KEY_NAME TIME_IN_UNIX_TIMESTAMP
Available Versions
= 1.0.0
Return Value
Returns 1 if the setting is successful. Returns 0 if the key does not exist or if the expiration time cannot be set for the key (for example, when trying to update the expiration time of a key in a Redis version below 2.1.3).
Example
First, create a key and assign a value:
redis 127.0.0.1:6379> SET tutorialprokey redis
OK
Set the expiration time for the key:
redis 127.0.0.1:6379> EXPIREAT tutorialprokey 1293840000
(integer) 1
redis 127.0.0.1:6379> EXISTS tutorialprokey
(integer) 0