Repository navigation
feat(client): add set member expiration commands - #3557
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.
💡 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".
| DELETED: 2 | ||
| } as const; | ||
|
|
||
| export type SetExpiration = typeof SET_EXPIRATION[keyof typeof SET_EXPIRATION]; |
There was a problem hiding this comment.
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 👍 / 👎.
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.
62f9bbb to
f52dd83
Compare
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,SPTTLandSTTL.They work like the hash field expiration commands and use the same API shape, with
membersin place offields:sAddEx(key, members, { mode?: 'MNX' | 'MXX', expiration?: { type: 'EX' | 'PX' | 'EXAT' | 'PXAT', value } | 'KEEPTTL' })returns0 | 1. WithoutKEEPTTL, it discards existing member expirations.sExpire/spExpire/sExpireAt/spExpireAt(key, members, time, mode?: 'NX' | 'XX' | 'GT' | 'LT') return one result for each member. TheSET_MEMBER_EXPIRATIONconstants name the values:-2means the member does not exist,0means the condition was not met,1means the expiration was updated, and2means the member was deleted. The...Atvariants accept anumberor aDate.sTTL/spTTL/sExpireTime/spExpireTime/sPersist(key, members) return one number for each member. TheSET_MEMBER_EXPIRATION_TIMEconstants 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
npm testpass with this change (including linting)?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).SADDEXadds members with optionalMNX/MXXand expiration (EX/PX/EXAT/PXAT/KEEPTTL), using theMEMBERSargument layout. The rest mirror key-level and hash-field TTL APIs but target individual set members:SEXPIRE/SEXPIREAT/SPEXPIRE/SPEXPIREAT(withNX/XX/GT/LT),SEXPIRETIME/SPEXPIRETIME,STTL/SPTTL, andSPERSIST. Shared reply semantics are exported asSET_MEMBER_EXPIRATIONandSET_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.