PTTL milliseconds

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Get the remaining expire time in milliseconds

Usage: pttl key [type].
Returns -2 if the key was deleted, and -1 if no expire time is set.
type is one of string/list/set/zset/hash/stream.
      The type argument was added in ent811. Please use it.

Example

Command>set key value
Result>1
Command>pexpire key 5000 string
Result>1
Command>pttl key string
Result>3546
Command>pttl key string
Result>-2
Command>get key
Result>(nil)


Syntax

PTTL key [type]

  • Available since version 2.6.0.
  • Time complexity is O(1).
  • The type argument was added in ent811.
Related commands SETEX, TTL, PERSIST, PSETEX, EXPIREAT, PEXPIRE, PEXPIREAT, PTTL
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< PEXPIREAT PTTL PERSIST >>

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