Redis PEXPIREAT Command

Redis key

The Redis PEXPIREAT command is used to set the expiration time of a key, measured in milliseconds. Once the key expires, it will no longer be available.

Syntax

The basic syntax of the Redis PEXPIREAT command is as follows:

redis 127.0.0.1:6379> PEXPIREAT KEY_NAME TIME_IN_MILLISECONDS_IN_UNIX_TIMESTAMP

Available Versions

>= 1.0.0

Return Value

Returns 1 if the setting is successful. Returns 0 when the key does not exist or the expiration time cannot be set for the key (for example, when you attempt to update the expiration time of a key in Redis versions lower than 2.1.3).

Examples

First create a key and assign a value:

redis 127.0.0.1:6379> SET examplekey redis
OK

Set the expiration time for the key:

redis 127.0.0.1:6379> PEXPIREAT examplekey 1555555555005
(integer) 1

Redis key

Other Extensions