PTTL
Syntax
PTTL key
Module
genericCategories
fast keyspace readDescription
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
- Go (Embedded)
- CLI
Retrieve the expiration time of a key:
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
ttl, err := db.PTTL("key")
Retrieve the expiration time of a key:
> PTTL key