Easy Tutorial
❮ Server Sync Sorted Sets Zremrangebyscore ❯

Redis PEXPIRE Command

Redis Key

The Redis PEXPIRE command is similar to the EXPIRE command, but it sets the key's time to live in milliseconds instead of seconds like the EXPIRE command.

Syntax

The basic syntax for the redis PEXPIRE command is as follows:

PEXPIRE key milliseconds

Available Versions

= 2.6.0

Return Value

Returns 1 if the setting is successful.

Returns 0 if the key does not exist or the setting fails.

Example

First, create a key and assign a value:

redis> SET mykey "Hello"
"OK"
redis> PEXPIRE mykey 1500
(integer) 1
redis> TTL mykey
(integer) 1
redis> PTTL mykey
(integer) 1498
redis>

Redis Key

❮ Server Sync Sorted Sets Zremrangebyscore ❯