PSETEX

Redis Developer Course Redis Cloud Service Redis-Gate Server

The key is removed after specified number of milliseconds

Use to specify fine expiration time. Usage is SETEX key milliseconds value.

Return value

  • milliseconds: if the key has an expiration time.
  • -1: If the key does not have an expiration time.
  • -2: If the key does not exist in the database.

Example

command>psetex key 10000 value
result>OK
command>pttl key
result>5687   Remaining time (milliseconds)
command>get key
result>value
command>get key
result>(nil)   Key is removed after 10000 milliseconds
The PTTL command returns the remaining time in milliseconds.


Syntax

PSETEX key milliseconds value

  • Available since 2.6.0.
  • Time complexity: O(1)
Related Commands SET, SETEX, PTTL, EXISTS
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

To practice the command, click here to run Redis Web Client


<< SETEX PSETEX MSET >>

Click for a question or to see comments.  Comments :    Viewed :

Email 답글이 올라오면 이메일로 알려드리겠습니다.