Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Expireat Command

Redis Expireat Command

Redis Key

The Redis Expireat command is used to set the expiration of a key in UNIX timestamp format. Once the key expires, it will no longer be available.

Syntax

The basic syntax of the redis Expireat command is as follows:



redis 127.0.0.1:6379> Expireat KEY_NAME TIME_IN_UNIX_TIMESTAMP

Available Version

= 1.0.0

Return Value

Returns 1 on success. Returns 0 when key does not exist or the timeout cannot be set (for example, when trying to update the timeout of a key in Redis versions lower than 2.1.3).

Example

First, create a key and assign a value:



redis 127.0.0.1:6379> SET runoobkey redis

OK

Set a timeout on the key:



redis 127.0.0.1:6379> EXPIREAT runoobkey 1293840000

(integer) 1

redis 127.0.0.1:6379> EXISTS runoobkey

(integer) 0

Redis Key