Skip to main content

PTTL

Syntax

PTTL key

Module

generic

Categories

fast keyspace read

Description

Returns the remaining time to live for a key that has an expiry time in milliseconds. If the key exists but does not have an associated expiry time, -1 is returned. If the key does not exist, -2 is returned.

Examples

Retrieve the expiration time of a key:

db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
ttl, err := db.PTTL("key")