Skip to content

feat(client): add set member expiration commands - #3557

Merged
nkaradzhov merged 3 commits into
redis:masterfrom
nkaradzhov:feat/set-member-expiration
Nov 3, 2026
Merged

nkaradzhov merged 3 commits into
redis:masterfrom
nkaradzhov:feat/set-member-expiration

Conversation

@nkaradzhov

@nkaradzhov nkaradzhov commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This pull request adds the set member expiration commands from Redis 8.12 (redis/redis#15938): SADDEX, SEXPIRE, SEXPIREAT, SEXPIRETIME, SPERSIST, SPEXPIRE, SPEXPIREAT, SPEXPIRETIME, SPTTL and STTL.

They work like the hash field expiration commands and use the same API shape, with members in place of fields:

  • sAddEx(key, members, { mode?: 'MNX' | 'MXX', expiration?: { type: 'EX' | 'PX' | 'EXAT' | 'PXAT', value } | 'KEEPTTL' }) returns 0 | 1. Without KEEPTTL, it discards existing member expirations.
  • sExpire / spExpire / sExpireAt / spExpireAt (key, members, time, mode?: 'NX' | 'XX' | 'GT' | 'LT') return one result for each member. The SET_MEMBER_EXPIRATION constants name the values: -2 means the member does not exist, 0 means the condition was not met, 1 means the expiration was updated, and 2 means the member was deleted. The ...At variants accept a number or a Date.
  • sTTL / spTTL / sExpireTime / spExpireTime / sPersist (key, members) return one number for each member. The SET_MEMBER_EXPIRATION_TIME constants name -2 (the member does not exist) and -1 (the member has no expiration).

Replies are the same on RESP2 and RESP3, and no command returns null. This PR also adds the ten new entries to the static command metadata table. The behavior tests are gated on Redis 8.12 and run in CI on the 8.12 image.


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Low Risk
Additive API following existing hash-expiration patterns; main caveat is server version requirement (8.12) and behavior tests not yet exercised in CI.

Overview
Adds client support for Redis 8.12 set member expiration—ten new commands wired through command parsers, the public command index (sAddEx, sExpire, spExpire, etc.), and regenerated command metadata (430 → 440 commands).

SADDEX adds members with optional MNX/MXX and expiration (EX/PX/EXAT/PXAT/KEEPTTL), using the MEMBERS argument layout. The rest mirror key-level and hash-field TTL APIs but target individual set members: SEXPIRE / SEXPIREAT / SPEXPIRE / SPEXPIREAT (with NX/XX/GT/LT), SEXPIRETIME / SPEXPIRETIME, STTL / SPTTL, and SPERSIST. Shared reply semantics are exported as SET_MEMBER_EXPIRATION and SET_MEMBER_EXPIRATION_TIME (aligned with the hash equivalents).

Each command includes argument-transform and integration specs; live behavior tests are gated on Redis ≥ 8.12 (CI 8.12 coverage called out as follow-up in the PR description).

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-02T19:25:11.171241Z f52dd83 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: 62f9bbb8be

ℹ️ 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 packages/client/lib/commands/SEXPIRE.ts Outdated
DELETED: 2
} as const;

export type SetExpiration = typeof SET_EXPIRATION[keyof typeof SET_EXPIRATION];

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 Preserve RESP number mapping in expiration status types

When callers configure withTypeMapping({ [RESP_TYPES.NUMBER]: String }), the decoder returns string entries for the four expiration-setting commands, but this bare numeric union causes sExpire, sExpireAt, spExpire, and spExpireAt to stay typed as (-2 | 0 | 1 | 2)[]. Numeric array replies elsewhere use the NumberReply marker; wrapping this union in NumberReply is needed so mapped callers do not get runtime strings behind a number-typed API.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment thread packages/client/lib/commands/SEXPIRE.ts Resolved
Add SADDEX, SEXPIRE, SEXPIREAT, SEXPIRETIME, SPERSIST, SPEXPIRE,
SPEXPIREAT, SPEXPIRETIME, SPTTL and STTL (Redis 8.12). They mirror the
hash field expiration commands, with members in place of fields, and
reply with the same shape on RESP2 and RESP3.

Register the new commands in the static command metadata table.
SET_EXPIRATION read like options for the SET command. Rename to
SET_MEMBER_EXPIRATION, SetMemberExpiration and SET_MEMBER_EXPIRATION_TIME
before they ship.
Wrap the SEXPIRE, SEXPIREAT, SPEXPIRE and SPEXPIREAT reply union in
NumberReply so a NUMBER type mapping applies to it.
@nkaradzhov
nkaradzhov force-pushed the feat/set-member-expiration branch from 62f9bbb to f52dd83 Compare November 2, 2026 19:20
@nkaradzhov
nkaradzhov merged commit 37df6c2 into redis:master Nov 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants