Skip to main content
Use GETEX to read a value and change its expiration in the same call. EX, PX, EXAT, and PXAT set a new lifetime or deadline, and PERSIST removes the expiration so the key stops expiring. With no option at all the expiration is left exactly as it was, which is the difference from GET plus a separate EXPIRE. Doing both at once is what makes a sliding expiration correct: reading a session extends it atomically, with no window in which the key could expire between the read and the refresh.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Related topics

GET