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

Redis PEXPIRE Command

Redis PEXPIRE Command

Redis Key

The Redis PEXPIRE command works similarly to the EXPIRE command, but it sets the time to live of a key in milliseconds instead of seconds.

Syntax

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



PEXPIRE key milliseconds

Available Version

= 2.6.0

Return Value

Returns 1 on success

Returns 0 if 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