EXPIRE
This page documents the preview (v2.21) version. Preview includes features under active development and is for development and testing only. For production, use the stable (v2024.1) version.
Synopsis
EXPIRE key timeout
Set a timeout on key (in seconds). After the timeout has expired, the key will automatically be deleted.
Return value
Returns integer reply, specifically 1 if the timeout was set and 0 if key does not exist.
Examples
$ SET yugakey "Yugabyte"
"OK"
$ EXPIRE yugakey 10
(integer) 1
$ EXPIRE non-existent-key 10
(integer) 0