EXPIRE

Synopsis

EXPIRE key timeoutSet 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

  1. $ SET yugakey "Yugabyte"
  1. "OK"
  1. $ EXPIRE yugakey 10
  1. (integer) 1
  1. $ EXPIRE non-existent-key 10
  1. (integer) 0

See also

expireat, ttl, pttl, set