Skip to content

feat: add set member expiration commands (SEXPIRE family and SADDEX) - #4543

Merged
petyaslavova merged 3 commits into
masterfrom
ps_add_set_member_expiration
Oct 30, 2026
Merged

petyaslavova merged 3 commits into
masterfrom
ps_add_set_member_expiration

Conversation

@petyaslavova

@petyaslavova petyaslavova commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

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, SPERSIST and SADDEX. The new SetCommands methods 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 for saddex, following HashDataPersistOptions on hsetex. saddex reuses extract_expire_flags and at_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.
  • The four read commands are added to the static command metadata table: sexpiretime/spexpiretime are client-side cacheable, while sttl/spttl are nondeterministic and not cached. The write commands stay out of the table, as the hash writes do.
  • CI: the 8.12.0 job uses the custom-40894365660-debian image, which carries the new commands. CURRENT_REDIS_VERSION moves to 8.10.3, the matrix moves to the latest patch releases, and docker-compose.yml defaults to 8.10.3.

Test coverage

Tests were added to tests/test_commands.py and tests/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, every saddex option and MNX/MXX outcome, client-side input errors, WRONGTYPE pass-through and pipelines. The metadata guards in tests/test_command_metadata.py are 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 SetCommands and 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: saddex plus sexpire / spexpire / sexpireat / spexpireat, spersist, and the read helpers sttl, spttl, sexpiretime, and spexpiretime. The new SetCommands APIs 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 for saddex, reusing the same mutual-exclusion checks as other expiry helpers.

Client-side cache metadata now classifies sexpiretime and spexpiretime as cacheable reads and sttl/spttl as 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-compose default test images from 8.6.1 to 8.10.3. Broad sync/async integration tests (gated on server 8.11.240+) cover expiry semantics, saddex options, pipelines, and error paths.

Reviewed by Cursor Bugbot for commit 74ba61e. Bugbot is set up for automated code reviews on this repo. Configure here.

@petyaslavova petyaslavova added the feature New feature label Oct 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-10-30T13:16:09.364930Z 74ba61e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟑 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, and SetDataPersistOptions.
  • 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

Comment thread tests/test_command_metadata.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ 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".

Comment thread tests/test_commands.py Resolved
@petyaslavova
petyaslavova force-pushed the ps_add_set_member_expiration branch from bf8336d to f7112a2 Compare October 30, 2026 12:01
@petyaslavova
petyaslavova merged commit 71622b9 into master Oct 30, 2026
132 checks passed
@petyaslavova
petyaslavova deleted the ps_add_set_member_expiration branch October 30, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants