PEXPIRE key milliseconds

Available since 2.6.0.

Time complexity: O(1)

This command works exactly like EXPIRE but the time to live of the key is specified in milliseconds instead of seconds.

*Return value

Integer reply, specifically:

  • 1 if the timeout was set.
  • 0 if key does not exist.

*Examples

redis> SET mykey "Hello"

  1. "OK"

redis> PEXPIRE mykey 1500

  1. (integer) 1

redis> TTL mykey

  1. (integer) 1

redis> PTTL mykey

  1. (integer) 1497
redis>