Skip to main content

EXPIRE

Note

Official reference: EXPIRE.

Set a key lifetime in seconds.

Syntax

EXPIRE key seconds [NX | XX | GT | LT]

NX sets only absent expirations; XX changes existing expirations; GT/LT only extend/shorten them. A lifetime of zero or less deletes the key immediately.

Results

ReturnRowsContent
Update count--1 if timeout was set; 0 otherwise.

Example

SET demo:message hello
EXPIRE demo:message 60