refactor: Split multi-key StringSetAsync into separate StringSetAsync (MSET) and StringSetNXAsync (MSETNX) methods#265
Open
currantw wants to merge 8 commits intovalkey-io:mainfrom
Conversation
…lues, When) Add dedicated StringSetNXAsync method to IStringCommands for MSETNX command. Remove the overloaded StringSetAsync(values, When) from the GLIDE-native interface and BaseClient, along with associated TODO valkey-io#262 comments. Signed-off-by: currantw <taylor.curran@improving.com>
…ngSetNX Update Database.StringSetAsync(values, When, CommandFlags) to delegate When.Always to StringSetAsync(values) and When.NotExists to StringSetNXAsync(values). Add StringSetNX to IBatchStringCommands and BaseBatch. Remove TODO valkey-io#262 comments and update XML doc references. Signed-off-by: currantw <taylor.curran@improving.com>
…ctly Rename and update MSETNX integration tests to call StringSetNXAsync instead of StringSetAsync(values, When.NotExists). Signed-off-by: currantw <taylor.curran@improving.com>
There was a problem hiding this comment.
Pull request overview
Refactors multi-key string set APIs by splitting conditional MSETNX behavior into a dedicated GLIDE-native method while keeping the StackExchange.Redis-compatible When overload in the SER layer.
Changes:
- Replaced
IStringCommands.StringSetAsync(values, When)withStringSetNXAsync(values)forMSETNX. - Updated SER-compatible
IDatabaseAsync.StringSetAsync(values, When, flags)implementation to delegate toMSET/MSETNXappropriately. - Added batch support for
MSETNXviaIBatchStringCommands.StringSetNX(...)and corresponding base batch implementation; updated integration tests to use the new API.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Valkey.Glide.IntegrationTests/StringCommandTests.cs | Updates integration tests to call StringSetNXAsync directly. |
| sources/Valkey.Glide/Pipeline/IBatchStringCommands.cs | Adds new batch command surface for StringSetNX. |
| sources/Valkey.Glide/Pipeline/BaseBatch.StringCommands.cs | Implements batch enqueue method for MSETNX requests. |
| sources/Valkey.Glide/Commands/IStringCommands.cs | Replaces When-based multi-key set API with StringSetNXAsync. |
| sources/Valkey.Glide/BaseClient.StringCommands.cs | Implements StringSetNXAsync using Request.StringSetMultipleNX. |
| sources/Valkey.Glide/Abstract/IDatabaseAsync.StringCommands.cs | Updates SER interface docs/signature formatting; keeps When overload. |
| sources/Valkey.Glide/Abstract/Database.StringCommands.cs | Delegates SER When overload to GLIDE-native MSET/MSETNX methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
… into currantw/split-multi-key-string-set
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
Split the multi-key
StringSetAsync(values, When)method into separateStringSetAsync(MSET) andStringSetNXAsync(MSETNX) methods in the GLIDE-nativeIStringCommandslayer, consistent with all other Valkey GLIDE clients. The SER-compatibleIDatabaseAsynclayer retains its existingWhen-based overload, delegating internally to the new methods.Issue Link
Closes #262
Features and Behaviour Changes
IStringCommands.StringSetAsync(values, When)is removed and replaced byStringSetNXAsync(values)→Task<bool>(MSETNX).IStringCommands.StringSetAsync(values)→Task(MSET) is unchanged.IDatabaseAsync.StringSetAsync(values, When, CommandFlags)is preserved for StackExchange.Redis compatibility. It now delegates toStringSetAsync(values)forWhen.AlwaysandStringSetNXAsync(values)forWhen.NotExists.IBatchStringCommandsgains a newStringSetNX(values)batch command.Implementation
The core change is in
IStringCommands/BaseClient.StringCommands.cs, where theWhen-parameterized overload is replaced by a dedicatedStringSetNXAsyncmethod. The SER-compatibleDatabase.StringCommands.csdelegates to the appropriate GLIDE-native method, keeping the public SER API surface intact.Limitations
⚪ None
Testing
StringSetNXAsync_WhenKeysDoNotExists_SuccessandStringSetNXAsync_WhenKeysExist_Failure) to callStringSetNXAsyncdirectly instead ofStringSetAsync(values, When.NotExists).Related Issues
Task) and conditional (Task<bool>) multi-key set overloads."OK"string returns with void.Checklist
CHANGELOG.md,README.md,DEVELOPER.md, and other documentation files are updated.mainor releasemain, squash otherwise.