Replace raw numeric time parameters with TimeSpan and DateTimeOffset#258
Merged
currantw merged 35 commits intovalkey-io:mainfrom Apr 6, 2026
Merged
Conversation
Signed-off-by: currantw <taylor.curran@improving.com>
Replace raw long milliseconds parameter with TimeSpan in WaitAsync across interface, BaseClient, Request builder, Pipeline batch, and Abstract layer. Numeric conversion deferred to Request builder via (long)timeout.TotalMilliseconds. Signed-off-by: currantw <taylor.curran@improving.com>
…to TimeSpan Replace raw double seconds parameter with TimeSpan in all 3 SortedSetBlockingPopAsync overloads across interface, BaseClient, Request builder, Pipeline batch, and Abstract layer. Numeric conversion deferred to Request builder via timeout.TotalSeconds. Signed-off-by: currantw <taylor.curran@improving.com>
…imeOffset Consolidate HashExpireAsync/HashPExpireAsync into single HashExpireAsync(TimeSpan) and HashExpireAtAsync/HashPExpireAtAsync into single HashExpireAtAsync(DateTimeOffset). Request builder auto-selects HEXPIRE vs HPEXPIRE and HEXPIREAT vs HPEXPIREAT based on precision (milliseconds % 1000), mirroring the KeyExpireAsync pattern. Signed-off-by: currantw <taylor.curran@improving.com>
…teTimeOffset Replace long minIdleTimeInMs/idleTimeInMs with TimeSpan and long timeUnixMs with DateTimeOffset across StreamClaimAsync, StreamClaimIdsOnlyAsync, StreamAutoClaimAsync, StreamAutoClaimIdsOnlyAsync, and StreamPendingMessagesAsync. Drop InMs parameter name suffixes. Numeric conversion deferred to Request builder. Signed-off-by: currantw <taylor.curran@improving.com>
…PI changes Update all test call sites to use TimeSpan/DateTimeOffset instead of raw numeric types. Covers SortedSet unit tests, SortedSet/Generic/Hash/Stream integration tests, batch test utils, and CommandTests unit test assertions. Signed-off-by: currantw <taylor.curran@improving.com>
… conversions Extract intermediary variables (minIdleTime, idleTime, timestamp) in Database.StreamCommands.cs to improve readability of nullable time parameter conversions in StreamPendingMessagesAsync, StreamClaimAsync, and StreamClaimIdsOnlyAsync. Signed-off-by: currantw <taylor.curran@improving.com>
…ility. Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
…hExpireAsync, HashPExpireAsync, HashExpireAtAsync, HashPExpireAtAsync, HashExpireTimeAsync, HashPExpireTimeAsync, HashTtlAsync, HashPTtlAsync) from both IDatabaseAsync.HashCommands.cs and Database.HashCommands.cs. These will be re-added with correct SER-compatible signatures in issue valkey-io#259. Signed-off-by: currantw <taylor.curran@improving.com>
…iration Remove precision-based command selection (milliseconds % 1000 check) from HashExpireAsync and HashExpireAtAsync request builders. Always use HPEXPIRE and HPEXPIREAT under the hood since they are functionally identical to their seconds-precision counterparts. Clean up XML doc comments and remove duplicate unit tests. Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 2, 2026
currantw
commented
Apr 2, 2026
…bility layer These methods do not exist in StackExchange.Redis and were incorrectly placed in the Abstract compatibility layer. Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 2, 2026
Add param doc overrides for minIdleTimeInMs, idleTimeInMs, and timeUnixMs in IDatabaseAsync.StreamCommands.cs to correctly describe the long-based parameters instead of inheriting TimeSpan/DateTimeOffset descriptions from the GLIDE-native methods. Signed-off-by: currantw <taylor.curran@improving.com>
… param docs Remove StreamPendingMessagesAsync (with minIdleTimeInMs), StreamClaimAsync, and StreamClaimIdsOnlyAsync extended overloads from the Abstract layer as they do not exist in StackExchange.Redis. Update remaining param docs to match SER descriptions. Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 2, 2026
Signed-off-by: currantw <taylor.curran@improving.com>
…m documentation Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 2, 2026
…ey count overload Remove SortedSetBlockingPopAsync(ValkeyKey, long, Order, TimeSpan) which accepted a count parameter but silently ignored it. BZPOPMIN/BZPOPMAX do not support a COUNT argument at the protocol level, so this overload could never honor count > 1. The multi-key blocking variant (BZMPOP) correctly supports count and remains unchanged. Signed-off-by: currantw <taylor.curran@improving.com>
…param docs Signed-off-by: currantw <taylor.curran@improving.com>
77aaa04 to
3b461ab
Compare
Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 2, 2026
currantw
commented
Apr 2, 2026
Signed-off-by: currantw <taylor.curran@improving.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Valkey GLIDE’s public API surface to use idiomatic .NET time types (TimeSpan, DateTimeOffset) instead of raw numeric time parameters, and propagates those signature changes through request building, pipeline/batch APIs, Abstract (SER-compat) APIs, and tests.
Changes:
- Replaced numeric timeout/idle/expiry parameters with
TimeSpanandDateTimeOffsetacross commands (e.g., WAIT, blocking ZSET pop, stream claim/autoclaim, hash field expiry). - Consolidated hash field expiration APIs to millisecond-precision commands (
HPEXPIRE,HPEXPIREAT) and removed several Abstract-layer SER-compat overloads that were incorrect/not present in SER. - Updated unit/integration tests plus pipeline/batch interfaces and implementations to match the new signatures.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Valkey.Glide.UnitTests/SortedSetCommandTests.cs | Updated SortedSet blocking pop tests to use TimeSpan timeouts and removed tests for deleted overloads. |
| tests/Valkey.Glide.UnitTests/CommandTests.cs | Updated WAIT/hash expire/stream tests to use TimeSpan/DateTimeOffset and adjusted expected args. |
| tests/Valkey.Glide.IntegrationTests/StreamConsumerGroupTests.cs | Updated Stream claim/autoclaim/pending calls to TimeSpan min-idle / idle parameters. |
| tests/Valkey.Glide.IntegrationTests/StreamCommandTests.cs | Updated Stream claim/autoclaim error-path tests to pass TimeSpan. |
| tests/Valkey.Glide.IntegrationTests/SortedSetCommandTests.cs | Updated blocking timeout type to TimeSpan and adapted tests to the remaining blocking-pop overloads. |
| tests/Valkey.Glide.IntegrationTests/HashCommandTests.cs | Updated hash expire/expire-at tests to use TimeSpan and DateTimeOffset. |
| tests/Valkey.Glide.IntegrationTests/GenericCommandTests.cs | Updated WAIT tests to use TimeSpan and kept negative-timeout validation coverage. |
| tests/Valkey.Glide.IntegrationTests/BatchTestUtils.StreamTests.cs | Updated batch StreamClaim usage to TimeSpan. |
| tests/Valkey.Glide.IntegrationTests/BatchTestUtils.cs | Updated batch WAIT/ZSET blocking pop/hash expire call sites to TimeSpan and aligned batch API usage. |
| sources/Valkey.Glide/Pipeline/IBatchStreamCommands.cs | Updated batch stream command signatures/docs to TimeSpan/DateTimeOffset. |
| sources/Valkey.Glide/Pipeline/IBatchSortedSetCommands.cs | Updated batch sorted set blocking-pop signatures to TimeSpan and removed the single-key count overload. |
| sources/Valkey.Glide/Pipeline/IBatchHashCommands.cs | Consolidated batch hash expire/expire-at signatures to TimeSpan/DateTimeOffset. |
| sources/Valkey.Glide/Pipeline/IBatchGenericCommands.cs | Updated batch WAIT signature to accept TimeSpan. |
| sources/Valkey.Glide/Pipeline/ClusterBatch.cs | Updated explicit interface implementations to new stream time parameter types. |
| sources/Valkey.Glide/Pipeline/Batch.cs | Updated explicit interface implementations to new stream time parameter types. |
| sources/Valkey.Glide/Pipeline/BaseBatch.StreamCommands.cs | Updated batch stream command wrappers to pass through TimeSpan/DateTimeOffset. |
| sources/Valkey.Glide/Pipeline/BaseBatch.SortedSetCommands.cs | Updated batch sorted set blocking-pop wrappers and removed obsolete overload wiring. |
| sources/Valkey.Glide/Pipeline/BaseBatch.HashCommands.cs | Consolidated hash expire/expire-at wrappers to TimeSpan/DateTimeOffset. |
| sources/Valkey.Glide/Pipeline/BaseBatch.GenericCommands.cs | Updated batch WAIT wrapper signature to TimeSpan. |
| sources/Valkey.Glide/Internals/Request.String.cs | Minor request parsing change using string literals relying on GlideString implicit conversion. |
| sources/Valkey.Glide/Internals/Request.StreamCommands.cs | Updated stream request builders to accept TimeSpan/DateTimeOffset and convert to ms. |
| sources/Valkey.Glide/Internals/Request.SortedSetCommands.cs | Updated sorted set blocking-pop request builders to accept TimeSpan and serialize seconds. |
| sources/Valkey.Glide/Internals/Request.HashCommands.cs | Consolidated hash expire/expire-at request builders to accept TimeSpan/DateTimeOffset and always use ms-precision requests. |
| sources/Valkey.Glide/Internals/Request.GenericCommands.cs | Updated WAIT request builder to accept TimeSpan and serialize milliseconds. |
| sources/Valkey.Glide/Commands/IStreamCommands.cs | Updated stream command interfaces/docs to use TimeSpan/DateTimeOffset for time values. |
| sources/Valkey.Glide/Commands/ISortedSetCommands.cs | Updated sorted set blocking-pop timeout type to TimeSpan and removed a count overload. |
| sources/Valkey.Glide/Commands/IHashCommands.cs | Consolidated hash field expiration interface/docs to TimeSpan/DateTimeOffset and removed older numeric overload docs. |
| sources/Valkey.Glide/Commands/IGenericBaseCommands.cs | Updated WAIT interface/docs to use TimeSpan. |
| sources/Valkey.Glide/BaseClient.StreamCommands.cs | Updated BaseClient stream methods to accept TimeSpan/DateTimeOffset. |
| sources/Valkey.Glide/BaseClient.SortedSetCommands.cs | Updated BaseClient sorted set blocking pop to TimeSpan and removed the count overload implementation. |
| sources/Valkey.Glide/BaseClient.HashCommands.cs | Consolidated BaseClient hash expire/expire-at to TimeSpan/DateTimeOffset. |
| sources/Valkey.Glide/BaseClient.GenericCommands.cs | Updated BaseClient WAIT to accept TimeSpan. |
| sources/Valkey.Glide/Abstract/IDatabaseAsync.StreamCommands.cs | Partially updated stream docs/refs for time changes and removed an overload; signatures still use long ms for some methods. |
| sources/Valkey.Glide/Abstract/IDatabaseAsync.SortedSetCommands.cs | Removed SortedSetBlockingPopAsync Abstract overloads (SER mismatch). |
| sources/Valkey.Glide/Abstract/IDatabaseAsync.HashCommands.cs | Removed hash field expiration-related Abstract methods with incorrect SER signatures. |
| sources/Valkey.Glide/Abstract/IDatabaseAsync.GenericCommands.cs | Removed WAIT Abstract overload with flags (SER mismatch). |
| sources/Valkey.Glide/Abstract/Database.StreamCommands.cs | Updated Abstract stream wrappers to convert ms long inputs into TimeSpan for GLIDE-native calls. |
| sources/Valkey.Glide/Abstract/Database.SortedSetCommands.cs | Removed corresponding Abstract sorted set blocking-pop overload implementations. |
| sources/Valkey.Glide/Abstract/Database.HashCommands.cs | Removed corresponding Abstract hash field expire-related overload implementations. |
| sources/Valkey.Glide/Abstract/Database.GenericCommands.cs | Removed corresponding Abstract WAIT overload implementation. |
| SECURITY.md | Reformatted contact emails in markdown. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… into currantw/timespan-api-parameters Signed-off-by: currantw <taylor.curran@improving.com>
…on issues - Add ToMilliseconds and ToSeconds helpers to Request class that convert TimeSpan values via Ticks division instead of TotalMilliseconds/TotalSeconds (which return doubles and can produce fractional or imprecise values). - Replace all TotalMilliseconds, TotalSeconds, and (long)TotalMilliseconds casts across Request.*.cs files with the new helpers. - Simplify KeyExpireAsync to always use PExpire/PExpireAt (millisecond precision), removing unnecessary seconds-vs-milliseconds branching. Addresses review feedback on PR valkey-io#258. Signed-off-by: currantw <taylor.curran@improving.com>
The field is a TimeSpan, so the 'Secs' suffix is misleading. Rename to the unit-agnostic 'BlockingTimeout'. Signed-off-by: currantw <taylor.curran@improving.com>
- Update SortedSetCommandTests comment from 'blocking pop with multiple elements' to 'single-key blocking pop with next element' to match the single-element overload being called. - Update BatchTestUtils description from 'HashPExpire(...)' to 'HashExpire(...)' to match the renamed API method. Addresses review feedback on PR valkey-io#258. Signed-off-by: currantw <taylor.curran@improving.com>
Use inheritdoc path filter to exclude the inherited minIdleTime param doc (which describes a TimeSpan) so it doesn't conflict with the local minIdleTimeInMs param doc (which describes a long milliseconds value). Addresses review feedback on PR valkey-io#258. Signed-off-by: currantw <taylor.curran@improving.com>
jeremyprime
reviewed
Apr 2, 2026
… into currantw/timespan-api-parameters Signed-off-by: currantw <taylor.curran@improving.com>
…timeouts BZPOPMIN/BZPOPMAX accept fractional second timeouts at the protocol level. The long return type truncated sub-second values, causing e.g. TimeSpan.FromSeconds(0.1) to become 0 (block indefinitely). Signed-off-by: currantw <taylor.curran@improving.com>
… use PX - PubSub blocking Request methods now accept TimeSpan instead of uint, using ToMilliseconds() internally. Callers no longer cast manually. - GETEX StringGetSetExpiry uses PX (milliseconds) instead of EX (seconds) to avoid sending fractional values after ToSeconds was changed to double. - Fix pre-existing KeyExpire test expectations (PEXPIRE/PEXPIREAT). Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 3, 2026
currantw
commented
Apr 3, 2026
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
alexr-bq
approved these changes
Apr 4, 2026
Open
19 tasks
jeremyprime
approved these changes
Apr 6, 2026
… into currantw/timespan-api-parameters
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
Replace raw numeric types (
long,double) with idiomatic .NET time types (TimeSpan,DateTimeOffset) for all time-related parameters across the public API surface. Remove incorrect Abstract-layer (SER compatibility) overloads that don't exist in StackExchange.Redis.Issue Link
⚪ None — this addresses an API consistency gap identified during development.
Features and Behaviour Changes
GLIDE-native API signature updates
WaitAsynclong timeout(milliseconds)TimeSpan timeoutSortedSetBlockingPopAsyncdouble timeout(seconds)TimeSpan timeoutHashExpireAsynclong secondsTimeSpan expiryHashPExpireAsynclong millisecondsHashExpireAsync)HashExpireAtAsynclong unixSecondsDateTimeOffset expiryHashPExpireAtAsynclong unixMillisecondsHashExpireAtAsync)StreamClaimAsynclong minIdleTimeInMs,long? idleTimeInMs,long? timeUnixMsTimeSpan minIdleTime,TimeSpan? idleTime,DateTimeOffset? timestampStreamClaimIdsOnlyAsynclong minIdleTimeInMs,long? idleTimeInMs,long? timeUnixMsTimeSpan minIdleTime,TimeSpan? idleTime,DateTimeOffset? timestampStreamAutoClaimAsynclong minIdleTimeInMsTimeSpan minIdleTimeStreamAutoClaimIdsOnlyAsynclong minIdleTimeInMsTimeSpan minIdleTimeStreamPendingMessagesAsynclong? minIdleTimeInMsTimeSpan? minIdleTimeRemoved incorrect SER compatibility overloads
These methods were in the Abstract layer (
IDatabaseAsync/Database) but do not exist in StackExchange.Redis:WaitAsync(long, long, CommandFlags)SortedSetBlockingPopAsync(…, CommandFlags)(3 overloads)HashPersistAsync(…, CommandFlags)HashExpireAsync(…, CommandFlags)HashPExpireAsync(…, CommandFlags)HashExpireAtAsync(…, CommandFlags)HashPExpireAtAsync(…, CommandFlags)HashExpireTimeAsync(…, CommandFlags)HashPExpireTimeAsync(…, CommandFlags)HashTtlAsync(…, CommandFlags)HashPTtlAsync(…, CommandFlags)StreamPendingMessagesAsync(…, minIdleTimeInMs, CommandFlags)StreamClaimAsync(…, idleTimeInMs, timeUnixMs, …, CommandFlags)StreamClaimIdsOnlyAsync(…, idleTimeInMs, timeUnixMs, …, CommandFlags)Removed misleading overload
SortedSetBlockingPopAsync(ValkeyKey, long count, Order, double)Implementation
Internals/Request.*.cs).BaseClientpassesTimeSpan/DateTimeOffsetthrough without conversion.HPEXPIRE,HPEXPIREAT) since they are functionally identical to their seconds-precision counterparts, avoiding the need for precision-based command selection.ToGlideString()calls for string literals inRequest.StreamCommands.csby relying on implicit conversion.IBatch*Commands,BaseBatch.*Commands,Batch,ClusterBatch) updated to match the GLIDE-native API signatures.Limitations
⚪ None
Testing
CommandTests.csandSortedSetCommandTests.csto useTimeSpan/DateTimeOffsetparameters.GenericCommandTests.cs,SortedSetCommandTests.cs,HashCommandTests.cs,StreamCommandTests.cs,StreamConsumerGroupTests.cs, andBatchTestUtils*.cs.Related Issues
Checklist
This Pull Request is related to one issue.CHANGELOG.md,README.md,DEVELOPER.md, and other documentation files are updated.mainor releaseCreate merge commit if merging release branch intomain, squash otherwise.