Skip to content

[Redis 8.12] Support set member expiration (SME) commands - #4828

Merged
atakavci merged 4 commits into
redis:masterfrom
atakavci:ali/setMemberExpire
Nov 6, 2026
Merged

atakavci merged 4 commits into
redis:masterfrom
atakavci:ali/setMemberExpire

Conversation

@atakavci

@atakavci atakavci commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the ten set member expiration commands introduced in Redis 8.12: SEXPIRE, SPEXPIRE, SEXPIREAT, SPEXPIREAT, STTL, SPTTL, SEXPIRETIME, SPEXPIRETIME, SPERSIST and SADDEX. Every command comes in a multi-member form and a single-member convenience form, on the String and binary APIs, in pipelines and transactions, and on the legacy Jedis client.

Key Decisions & Assumptions

  • The API mirrors the existing hash field expiration methods: per-member replies come back as List<Long>, and the *expire* commands take an optional ExpiryOption (NX/XX/GT/LT) overload instead of a dedicated params class.
  • Single-member overloads (sexpire(key, seconds, member), sttl(key, member), saddex(key, params, member), and so on) return a plain long instead of a one-element list. They send the same MEMBERS 1 <member> wire form and unwrap the reply with a new BuilderFactory.LONG_FROM_LIST builder, so callers with one member avoid the list boilerplate.
  • SADDEX gets a SAddExParams class that extends BaseSetExParams for ex/px/exAt/pxAt/keepTtl and adds mnx()/mxx(). Each group is a last-call-wins slot, and the command appends the MEMBERS <count> block itself.
  • No client-side version check: on servers older than 8.12 the commands fail with the server's unknown-command error.
  • New public API is annotated @since 8.1.

Behavioral / Conceptual Changes

  • Existing set methods are untouched, but their Javadoc now documents how Redis 8.12 propagates member expiration: sunionstore keeps the farthest, sinterstore the nearest, sdiffstore the first set's, and smove moves the member with its expiration.
  • Release notes for 8.1.0 gain a "Set member expiration commands" entry.

Testing

Unit tests cover argument encoding for every command, in both multi-member and single-member form, across CommandObjects, UnifiedJedis and PipeliningBase, plus SAddExParams ordering, equality and overriding behavior. Integration tests in the shared set test base, the Jedis set tests, and the pipeline tests exercise reply codes (-2/-1/0/1/2), per-member NX/XX/GT/LT semantics, past-time deletion, SADDEX conditions and the zero-modification reply, wrong-type errors, and the single-member variants returning the same codes as their list counterparts. They are gated with @EnabledOnCommand("SADDEX") so they skip on older servers.


Note

Medium Risk
Broad new command surface and wire-format details tied to Redis 8.12 behavior; mistakes in argument ordering or reply parsing could confuse callers or break SME-heavy workloads, though the change is additive and guarded by integration tests.

Overview
Adds full client support for Redis 8.12 set member expiration: the sexpire / spexpire / sexpireAt / spexpireAt family (with optional ExpiryOption per member), sttl, spttl, sexpireTime, spexpireTime, spersist, and saddex backed by new SAddExParams (mnx / mxx plus ex / px / exAt / pxAt / keepTtl).

Multi-member calls return List<Long>; single-member overloads return a plain long, using new BuilderFactory.LONG_FROM_LIST to unwrap one-element array replies while still emitting MEMBERS 1 … on the wire. String and binary paths, UnifiedJedis, legacy Jedis, pipelines, and the various Set* command interfaces are all extended, and Protocol registers the new commands plus MEMBERS, MNX, and MXX keywords.

Docs and semantics: 8.1.0 release notes describe the commands; Javadoc on sdiffstore, sinterstore, sunionstore, and smove calls out how member expirations propagate in Redis 8.12. Tests add command-object, unified, pipeline, mocked, and integration coverage (including conditions, past-time deletes, saddex edge cases, wrong-type handling, and single-member variants), gated with @EnabledOnCommand("SADDEX") so they skip on servers without SME.

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

@atakavci
atakavci requested review from a-TODO-rov and ggivo November 4, 2026 14:41
@atakavci atakavci self-assigned this Nov 4, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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-11-06T10:06:00.077601Z 01c6beb 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.

@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: afddc1ee6e

ℹ️ 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".


private Keyword condition;

public static SAddExParams sAddExParams() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add @SInCE to the new parameter methods

The factory is new public API, as are mnx() and mxx(), but only the class-level Javadoc carries @since; generated method-level API documentation therefore cannot identify when these entry points were added. Add @since 8.1 to each of these three public methods.

AGENTS.md reference: AGENTS.md:L27-L31

Useful? React with 👍 / 👎.

@ggivo ggivo changed the title Support set member expiration(SME) commands (Redis 8.12) [8.12] Support set member expiration(SME) commands (Redis 8.12) Nov 5, 2026
@ggivo ggivo added this to the 8.1.0 milestone Nov 5, 2026

@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: ba5471e6b4

ℹ️ 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".

* The single integer of a one-element integer array reply, for the single-member variants of
* commands that reply with one integer per member (e.g. {@code SEXPIRE key 10 MEMBERS 1 m}).
*/
public static final Builder<Long> LONG_FROM_LIST = new Builder<Long>() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add @SInCE to the new response builder

When the 8.1 API documentation is generated, the newly exposed public LONG_FROM_LIST builder has no @since 8.1 tag, so consumers cannot determine when this API became available; add the tag to this declaration.

AGENTS.md reference: AGENTS.md:L27-L31

Useful? React with 👍 / 👎.

@ggivo ggivo changed the title [8.12] Support set member expiration(SME) commands (Redis 8.12) [Redis 8.12] Support set member expiration (SME) commands Nov 6, 2026

@ggivo ggivo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@atakavci
atakavci merged commit e7c37d3 into redis:master Nov 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants