Skip to main content

GETEX

Note

Official reference: GETEX.

Read a string while setting or removing its expiration.

Syntax

GETEX key [EX seconds | PX milliseconds | EXAT unix-seconds | PXAT unix-milliseconds | PERSIST]

EX/PX set lifetimes in seconds/milliseconds; EXAT/PXAT set Unix expiration timestamps; PERSIST removes expiration.

A missing key returns one row with a null VALUE.

Expiration arguments support 64-bit integers, as literals or bound Java long values. PXAT accepts Unix millisecond timestamps directly.

Results

ReturnRowsContent
ResultSet1VALUE field, STRING type

Example

SET demo:message hello
GETEX demo:message EX 60