fix: add hSetNX to Redis transaction interface#248
Open
mvanhorn wants to merge 1 commit intoreddit:mainfrom
Open
fix: add hSetNX to Redis transaction interface#248mvanhorn wants to merge 1 commit intoreddit:mainfrom
mvanhorn wants to merge 1 commit intoreddit:mainfrom
Conversation
Fixes reddit#184 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
logan
reviewed
Mar 18, 2026
niedzielski
approved these changes
Mar 19, 2026
stephenoid
approved these changes
Mar 19, 2026
Member
|
@mvanhorn, would you please sign our contributor agreement? |
Author
|
Signed the CLA. |
Contributor
|
thanks! i'll try to merge this monday. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
hSetNXto the Redis transaction interface (TxClientLike) and both transaction class implementations. The method exists in the non-transactionRedisClientbut was missing from transactions.Why this matters
#184 reports that
hSetNXis unavailable in transactions. TheTxClientLiketype hashSet,hGet,hMGet,hGetAll,hDel,hScan,hKeys,hIncrBy, andhLenbut nothSetNX. This makes it impossible to use atomic hash-set-if-not-exists operations within Redis transactions.Changes
packages/redis/src/types/redis.ts- AddedhSetNXtoTxClientLiketypepackages/redis/src/RedisClient.ts- AddedhSetNXto the transaction class, following the same pattern ashSet(queue withtransactionId, returnthis)packages/public-api/src/apis/redis/RedisClient.ts- AddedhSetNXand lowercasehsetnxalias to the public-api transaction class, matching the alias pattern used byhset/hSet,hincrby/hIncrBy, etc.Testing
The implementation follows the exact pattern of existing hash methods in the transaction classes. No new test infrastructure was needed - the method signature and behavior matches the non-transaction
hSetNX(queuing the command withtransactionIdinstead ofscope).Fixes #184
This contribution was developed with AI assistance (Claude Code + Codex CLI).