Repository navigation
feat: add set member expiration commands (SEXPIRE family and SADDEX) - #4543
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with π while any review is running, comments if it has suggestions, and reacts with π once all reviews finish with no findings. |
There was a problem hiding this comment.
π‘ Changes recommended
The live-metadata tests still allow Redis 8.11.0 even though the four new commands require 8.11.240 or 8.12, causing comparison and eligibility assertions to fail on earlier 8.11 builds.
1 open issue
What changed in this PR
Adds Redis 8.12 set member expiration support to redis-py through the shared command mixin, exposing the commands to sync and async clients, clusters, and pipelines.
Changes:
- Adds
SADDEX, the set member expiration command family, andSetDataPersistOptions. - Registers read-command metadata, enabling caching for expiration timestamps but not remaining TTLs.
- Adds sync/async coverage and refreshes CI and Docker images.
| File | Description |
|---|---|
tests/βtest_commands.py |
Adds synchronous expiration, option-validation, and pipeline tests. |
tests/βtest_command_metadata.py |
Updates cache eligibility expectations. |
tests/βtest_asyncio/βtest_commands.py |
Adds matching asynchronous command tests. |
redis/βcommands/βmetadata.py |
Registers routing and cacheability metadata for four reads. |
redis/βcommands/βcore.py |
Implements ten commands with sync/async overloads and documentation. |
docker-compose.yml |
Updates default Redis images to 8.10.3. |
.github/βworkflows/βintegration.yaml |
Refreshes version coverage and selects the preview image. |
Review effort: Balanced
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf8336dedb
βΉοΈ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
bf8336d to
f7112a2
Compare

Change summary
This pull request adds support for the set member expiration commands introduced in Redis 8.12 (redis/redis#15938):
SEXPIRE,SPEXPIRE,SEXPIREAT,SPEXPIREAT,STTL,SPTTL,SEXPIRETIME,SPEXPIRETIME,SPERSISTandSADDEX. The newSetCommandsmethods mirror the existing hash field expiration methods (hexpire...hpttl,hsetex) in shape, so sync and async clients, cluster, pipelines and transactions get them through the shared mixin. Arguments and replies pass through unchanged: every member command returns one integer per member in request order.SetDataPersistOptions(MNX/MXX) is added forsaddex, followingHashDataPersistOptionsonhsetex.saddexreusesextract_expire_flagsandat_most_one_value_set, and returns 1 only when at least one member was added, updated or deleted, as the merged server reply schema defines it.sexpiretime/spexpiretimeare client-side cacheable, whilesttl/spttlare nondeterministic and not cached. The write commands stay out of the table, as the hash writes do.custom-40894365660-debianimage, which carries the new commands.CURRENT_REDIS_VERSIONmoves to 8.10.3, the matrix moves to the latest patch releases, anddocker-compose.ymldefaults to 8.10.3.Test coverage
Tests were added to
tests/test_commands.pyandtests/test_asyncio/test_commands.py, gated on 8.11.240. They cover real expiry, timedelta/datetime arguments, the NX/XX/GT/LT conditions (including a member without an expiration counting as infinite), missing keys and members, past times deleting members and the key, STTL/SEXPIRETIME rounding, everysaddexoption and MNX/MXX outcome, client-side input errors, WRONGTYPE pass-through and pipelines. The metadata guards intests/test_command_metadata.pyare updated for the two newly cacheable reads. All of this passed locally with RESP2, RESP3 and unified responses, in standalone and cluster.Note
Medium Risk
Large new surface in
SetCommandsand CSC metadata could mis-cache TTL reads or mis-encode command arguments; impact is limited to Redis 8.12+ servers and is heavily tested.Overview
Adds client support for Redis 8.12 set member expiration:
saddexplussexpire/spexpire/sexpireat/spexpireat,spersist, and the read helperssttl,spttl,sexpiretime, andspexpiretime. The newSetCommandsAPIs follow the existing hash field expiration shape (expiry flags, NX/XX/GT/LT on writes, per-member integer replies, sync/async overloads).SetDataPersistOptions(MNX/MXX) is introduced forsaddex, reusing the same mutual-exclusion checks as other expiry helpers.Client-side cache metadata now classifies
sexpiretimeandspexpiretimeas cacheable reads andsttl/spttlas nondeterministic (not cached); metadata tests and eligibility guards are updated accordingly.CI and local Docker bump the current Redis patch level to 8.10.3, refresh supported matrix patch versions, point the 8.12.0 job at a custom image that includes the new commands, and raise
docker-composedefault test images from 8.6.1 to 8.10.3. Broad sync/async integration tests (gated on server 8.11.240+) cover expiry semantics,saddexoptions, pipelines, and error paths.Reviewed by Cursor Bugbot for commit 74ba61e. Bugbot is set up for automated code reviews on this repo. Configure here.