fix: Remove unnecessary Task<bool> return types from GLIDE-native methods#261
Merged
currantw merged 11 commits intovalkey-io:mainfrom Apr 3, 2026
Merged
Conversation
The RENAME command always returns OK or throws — the bool was always true and conveyed no useful information. Change the GLIDE-native interface and BaseClient implementation to return Task (void). The SER-compatible Database wrapper continues to return Task<bool> for StackExchange.Redis API compatibility. Signed-off-by: currantw <taylor.curran@improving.com>
…and add new overloads - Change single-key StringSetAsync(key, value) from Task<bool> to Task - Add unconditional multi-key overload StringSetAsync(values) returning Task - Remove default When.Always from existing multi-key conditional overload - Add conditional single-key overload StringSetAsync(key, value, When) - Add Request.StringSetNX and Request.StringSetXX for SET NX/XX support - SER-compatible Database wrappers continue to return Task<bool> Signed-off-by: currantw <taylor.curran@improving.com>
…erGroupSetPositionAsync to Task Both XGROUP CREATE and XGROUP SETID always return OK or throw — the bool was always true. Change the GLIDE-native interface and BaseClient implementations to return Task (void). SER-compatible Database wrappers continue to return Task<bool> for StackExchange.Redis API compatibility. Signed-off-by: currantw <taylor.curran@improving.com>
- Add ReturnTypeTests verifying GLIDE-native methods return Task (void) - Add ReturnTypeTests verifying SER-compatible methods retain Task<bool> - Add ReturnTypeTests for new StringSetAsync overloads and When parameter - Add preservation tests for KeyRenameNXAsync, StreamDeleteConsumerGroupAsync, and StreamCreateConsumerAsync (unchanged Task<bool> methods) - Add Request.StringSetNX/XX argument and converter tests in CommandTests Signed-off-by: currantw <taylor.curran@improving.com>
- Update StringSetAsync calls to use void return where applicable - Update StreamCreateConsumerGroupAsync and StreamConsumerGroupSetPositionAsync calls to use void return - Add conditional single-key StringSetAsync(key, value, When) integration tests - Update all test files that called affected methods with bool assertions Signed-off-by: currantw <taylor.curran@improving.com>
…wrappers StreamCreateConsumerGroupAsync and StreamConsumerGroupSetPositionAsync SER wrappers in Database were resolving to their own overloads (with default parameters) instead of the BaseClient methods, causing infinite recursion. Cast to BaseClient explicitly to ensure correct dispatch to the void-returning GLIDE-native methods. Signed-off-by: currantw <taylor.curran@improving.com>
Remove reflection-based return type verification tests. The return type contracts are already enforced by the compiler at integration test call sites and by the interface definitions themselves. Signed-off-by: currantw <taylor.curran@improving.com>
…gle-key StringSetAsync Add tests for the When.Always branch of the new StringSetAsync(key, value, When) overload, covering both key-exists and key-does-not-exist scenarios. Signed-off-by: currantw <taylor.curran@improving.com>
There was a problem hiding this comment.
Pull request overview
This PR cleans up async return types for several Valkey GLIDE “always succeeds or throws” commands by removing misleading Task<bool> results at the command-interface/client layers, adding conditional SET support (NX/XX) for single-key sets, and updating tests/call-sites accordingly.
Changes:
- Updated GLIDE-native command interfaces and
BaseClientimplementations to returnTask(void) for commands that only returnOKor throw. - Added request builders for
SET NX/SET XXand introduced a new conditional single-keyStringSetAsync(key, value, When)overload. - Updated unit/integration tests and StackExchange-facing wrappers/call-sites to align with new return types and overload resolution.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Valkey.Glide.UnitTests/CommandTests.cs | Adds unit coverage for Request.StringSetNX/StringSetXX args + converters. |
| tests/Valkey.Glide.IntegrationTests/StringCommandTests.cs | Updates unconditional StringSetAsync usage to void; adds integration tests for When single-key set branches. |
| tests/Valkey.Glide.IntegrationTests/StreamConsumerGroupTests.cs | Updates stream consumer group create/set-position calls to void-returning APIs. |
| tests/Valkey.Glide.IntegrationTests/StreamCommandTests.cs | Updates stream group creation calls to void-returning API. |
| tests/Valkey.Glide.IntegrationTests/StandaloneClientTests.cs | Adjusts set usage to void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/StackExchange/ValkeyServerTests.cs | Updates StackExchange-facing tests to not expect boolean from unconditional StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/SharedBatchTests.cs | Updates setup writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/ScriptingCommandTests.cs | Updates script test setup writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/ScanTests.cs | Updates scan test setup writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/ReadFromTests.cs | Updates read-from tests to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/OpenTelemetryTests.cs | Updates telemetry test writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/GeospatialCommandTests.cs | Updates wrong-type setup writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/GenericCommandTests.cs | Updates rename/set usage to match void-returning KeyRenameAsync and StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/FlushDatabaseTests.cs | Updates flush tests setup writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/DBTests.cs | Updates DB smoke test to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/ClusterClientTests.cs | Updates cluster tests setup writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/BitmapCommandTests.cs | Updates bitmap tests setup writes to use void-returning StringSetAsync. |
| tests/Valkey.Glide.IntegrationTests/BatchTests.cs | Updates batch/transaction tests to treat StringSetAsync as void-returning when called without flags. |
| sources/Valkey.Glide/Internals/Request.String.cs | Adds Request.StringSetNX and Request.StringSetXX builders handling nullable responses. |
| sources/Valkey.Glide/Commands/IStringCommands.cs | Changes unconditional StringSetAsync/multi-set to Task; adds conditional single-key overload and removes default When on multi-set conditional overload. |
| sources/Valkey.Glide/Commands/IStreamCommands.cs | Changes consumer group create/set-position return types to Task (void). |
| sources/Valkey.Glide/Commands/IGenericBaseCommands.cs | Changes KeyRenameAsync return type to Task (void). |
| sources/Valkey.Glide/BaseClient.StringCommands.cs | Implements new void-returning set overloads and When-based single-key conditional set. |
| sources/Valkey.Glide/BaseClient.StreamCommands.cs | Updates consumer group create/set-position implementations to void-returning behavior. |
| sources/Valkey.Glide/BaseClient.GenericCommands.cs | Updates KeyRenameAsync implementation to void-returning behavior. |
| sources/Valkey.Glide/Abstract/Database.StringCommands.cs | Preserves a Task<bool> StackExchange-facing overload by awaiting void set and returning true. |
| sources/Valkey.Glide/Abstract/Database.StreamCommands.cs | Preserves Task<bool> StackExchange-facing overloads and fixes overload recursion via ((BaseClient)this) dispatch. |
| sources/Valkey.Glide/Abstract/Database.GenericCommands.cs | Preserves a Task<bool> StackExchange-facing overload by awaiting void rename and returning true. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… into currantw/remove-unnecessary-bool-return-types
…ulti-key StringSetAsync Change multi-key StringSetAsync to throw ArgumentException (instead of NotImplementedException) for unsupported When values, matching StackExchange.Redis behavior. Document supported When values and add TODO valkey-io#262 comments for future refactor into separate StringSetNXAsync method. Addresses review comment on PR valkey-io#261. Signed-off-by: currantw <taylor.curran@improving.com>
Mark methods in shared I*Commands interfaces that need to move to IClient.* partials once the GLIDE/SER API surface separation is implemented. Also mark IDatabaseAsync inheritance declaration. Signed-off-by: currantw <taylor.curran@improving.com>
jeremyprime
approved these changes
Apr 2, 2026
alexr-bq
approved these changes
Apr 2, 2026
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
Remove misleading
Taskreturn types from four GLIDE-native methods where the boolean was alwaystrue. The underlying Valkey commands (RENAME, unconditionalSET,XGROUP CREATE,XGROUP SETID) always returnOKor throw — they never returnfalse. Changed these methods to returnTask(void) at the GLIDE-native layer, while SER-compatible wrappers inDatabasecontinue to returnTaskfor StackExchange.Redis API compatibility.This continues the return type cleanup started in #230, which replaced
"OK" string returns with void. This PR addresses the remaining cases whereTask` was used for commands that always succeed or throw.Also adds two new
StringSetAsyncconvenience overloads.Issue Link
⚪ None.
Features and Behaviour Changes
Return type changes for Valkey GLIDE interface:
KeyRenameAsync(ValkeyKey, ValkeyKey):Task→TaskStringSetAsync(ValkeyKey, ValkeyValue):Task→TaskStreamCreateConsumerGroupAsync(both overloads):Task→TaskStreamConsumerGroupSetPositionAsync:Task→TaskNew
StringSetAsyncoverloads:Task StringSetAsync(IEnumerable> values)Task StringSetAsync(ValkeyKey key, ValkeyValue value, When when)Default parameter removal:
When.Alwaysdefault fromStringSetAsync(IEnumerable> values, When when)to prevent ambiguity between unconditional (Task) and conditional (Task) overloadsException type fix for multi-key
StringSetAsyncwith unsupportedWhenvalues:When.Existsto throwArgumentExceptioninstead ofNotImplementedException, matching StackExchange.Redis behavior (SER throwsArgumentExceptionvia its internalWhenAlwaysOrNotExistsguard)ArgumentException(wasArgumentOutOfRangeException)IStringCommandsto document supportedWhenvalues and theArgumentExceptionTODO #262comments for future refactor into separateStringSetNXAsyncmethodImplementation
Valkey GLIDE interface (
Commands/I*Commands.cs,BaseClient.*Commands.cs):TasktoTaskfor the four affected methodsBaseClientimplementations discard the bool result using_ = await Command(...)Request.StringSetNXandRequest.StringSetXXforSET NX/SET XXsupport in the new conditional single-key overloadStackExchange.Redis interface (
Abstract/Database.*Commands.cs):awaitthe base GLIDE-native void methods andreturn true, preservingTaskfor StackExchange.Redis compatibilityDatabase.StreamCommands.csby casting to((BaseClient)this)to ensure dispatch to the correct base methods instead of theDatabaseoverloads with default parametersStackExchange.Redis compatibility:
CommandFlagsparameter) inIDatabaseAsyncandDatabaseretain theirTaskreturn typesKeyRenameNXAsync,StringSetAsyncwithWhen.NotExists/When.Exists,StreamDeleteConsumerGroupAsync,StreamCreateConsumerAsyncIDatabaseAsync.*Commands.cs) required no changesLimitations
⚪ None
Testing
Unit tests:
Request.StringSetNX/StringSetXXargument builder and converter tests inCommandTests.csIntegration tests:
StringSetAsync(key, value, When)integration tests coveringWhen.NotExists,When.Exists, andWhen.AlwaysbranchesRelated Issues
cleanup: replace "OK" string returns with void)StringSetAsyncinto separateStringSetAsync(MSET) andStringSetNXAsync(MSETNX) methods #262 — split multi-keyStringSetAsyncinto separateStringSetAsync/StringSetNXAsyncmethodsIClientinterface to separate GLIDE-native and SER-compatible API surfaces #263 — introduceIClientinterface to separate GLIDE-native and SER-compatible API surfacesChecklist
This Pull Request is related to one issue.CHANGELOG.md,README.md,DEVELOPER.md, and other documentation files are updated.mainor releasemain, squash otherwise.