Skip to content

refactor: Split multi-key StringSetAsync into separate StringSetAsync (MSET) and StringSetNXAsync (MSETNX) methods#265

Open
currantw wants to merge 8 commits intovalkey-io:mainfrom
currantw:currantw/split-multi-key-string-set
Open

refactor: Split multi-key StringSetAsync into separate StringSetAsync (MSET) and StringSetNXAsync (MSETNX) methods#265
currantw wants to merge 8 commits intovalkey-io:mainfrom
currantw:currantw/split-multi-key-string-set

Conversation

@currantw
Copy link
Copy Markdown
Collaborator

@currantw currantw commented Apr 3, 2026

Summary

Split the multi-key StringSetAsync(values, When) method into separate StringSetAsync (MSET) and StringSetNXAsync (MSETNX) methods in the GLIDE-native IStringCommands layer, consistent with all other Valkey GLIDE clients. The SER-compatible IDatabaseAsync layer retains its existing When-based overload, delegating internally to the new methods.

Issue Link

Closes #262

Features and Behaviour Changes

  • IStringCommands.StringSetAsync(values, When) is removed and replaced by StringSetNXAsync(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 to StringSetAsync(values) for When.Always and StringSetNXAsync(values) for When.NotExists.
  • IBatchStringCommands gains a new StringSetNX(values) batch command.

Implementation

The core change is in IStringCommands / BaseClient.StringCommands.cs, where the When-parameterized overload is replaced by a dedicated StringSetNXAsync method. The SER-compatible Database.StringCommands.cs delegates to the appropriate GLIDE-native method, keeping the public SER API surface intact.

Limitations

⚪ None

Testing

  • Updated two integration tests (StringSetNXAsync_WhenKeysDoNotExists_Success and StringSetNXAsync_WhenKeysExist_Failure) to call StringSetNXAsync directly instead of StringSetAsync(values, When.NotExists).
  • All 500 unit tests pass. Build and lint checks pass.

Related Issues

  • PR #261 — return type cleanup that introduced the current split between unconditional (Task) and conditional (Task<bool>) multi-key set overloads.
  • PR #230 — earlier return type cleanup that replaced "OK" string returns with void.

Checklist

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated and all checks pass.
  • CHANGELOG.md, README.md, DEVELOPER.md, and other documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

currantw added 3 commits April 2, 2026 21:47
…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>
@currantw currantw self-assigned this Apr 3, 2026
@currantw currantw requested a review from Copilot April 3, 2026 05:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) with StringSetNXAsync(values) for MSETNX.
  • Updated SER-compatible IDatabaseAsync.StringSetAsync(values, When, flags) implementation to delegate to MSET/MSETNX appropriately.
  • Added batch support for MSETNX via IBatchStringCommands.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.

currantw added 2 commits April 3, 2026 12:55
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
currantw added 3 commits April 3, 2026 14:26
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
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.

refactor: Split multi-key StringSetAsync into separate StringSetAsync (MSET) and StringSetNXAsync (MSETNX) methods

2 participants