Redis 6.2.0, released on February 22, 2021, adds GETEX, a command that reads a string value and can change when its key expires. For application teams using Redis to hold temporary data, the choice is whether a read should renew the expiry, leave it alone or remove it. Installing the release does not choose that policy: the options sent with the command do. [S1][S2]

The difference between a sliding timeout and a fixed deadline sits in the arguments. EX sets a time to live in seconds; PX uses milliseconds. EXAT and PXAT instead take an absolute Unix timestamp, in seconds and milliseconds respectively. For example, repeatedly sending GETEX with EX 600 would give an existing string key another 600 seconds on each successful call. That can suit an inactivity timeout, but it is a poor substitute for a fixed deletion deadline. The release implementation calculates relative expiry from the current time; its absolute-time options use the supplied timestamp. [S2][S3]

A plain GETEX call does not renew the timer. The 6.2.0 implementation explicitly gives it the same default behavior as GET, with the existing time to live unchanged. PERSIST makes a different choice: it removes any expiry attached to the key. The project's tests illustrate that transition by creating a string with a ten-second expiry, calling GETEX with PERSIST, and checking that TTL returns -1, indicating no expiry. PERSIST is therefore not a way to pause or lengthen the countdown. It removes it. [S2][S3]

The name can mislead a routing review. Redis documents GETEX in its source as not read-only, unlike GET. The implementation changes expiry metadata when an expiry option is supplied and propagates the resulting expiry or persistence operation, rather than forwarding GETEX unchanged. A separate test checks that a call without options is not propagated to a replica. The practical implication is to review GETEX as a write-capable command, not assume that every operation beginning with GET belongs on an application's read-only route. [S2][S3]

There are limits to what a successful read establishes. GETEX returns null when the key is absent and rejects a value of the wrong type rather than converting it to a string. With a valid positive absolute timestamp that has already elapsed, the implementation returns the existing string value and then deletes the key; zero or negative timestamps are rejected with an error before the value is returned. A caller can therefore receive data without that key remaining available for the next request. Code that treats a returned value as proof of a renewed cache entry needs to distinguish that case from a relative timeout. [S2]

Source documents

  1. Redis 6.2.0 release noteshttps://raw.githubusercontent.com/redis/redis/6.2.0/00-RELEASENOTES
  2. Redis 6.2.0 string command implementation: GETEXhttps://raw.githubusercontent.com/redis/redis/6.2.0/src/t_string.c
  3. Redis 6.2.0 string command testshttps://raw.githubusercontent.com/redis/redis/6.2.0/tests/unit/type/string.tcl