Skip to content

feat/stream trim modes - #355

Closed
Echways wants to merge 2 commits into
valkey-io:mainfrom
Echways:feat/stream-trim-modes
Closed

Echways wants to merge 2 commits into
valkey-io:mainfrom
Echways:feat/stream-trim-modes

Conversation

@Echways

@Echways Echways commented Apr 29, 2026

Copy link
Copy Markdown

Summary

Adds support for the Valkey 8.2 stream trim modes DELREF and ACKED in the C# client.

Issue Link

This pull request is linked to issue: Closes #311

Features and Behaviour Changes

  • Adds DeleteReferences and Acknowledged values to StreamTrimMode.
  • Allows StreamTrimOptions to emit DELREF and ACKED for stream trimming.
  • Adds trim mode support to XTRIM command argument construction.
  • Keeps the default KeepReferences behavior unchanged and does not emit KEEPREF, preserving backward compatibility with older servers.

Implementation

  • Added stream trim mode literals for DELREF and ACKED.
  • Added an internal StreamTrimModeExtensions.ToKeyword() helper to centralize mapping from StreamTrimMode to command keywords.
  • Updated StreamTrimOptions.ToArgs() to append the trim mode keyword after LIMIT, matching the command syntax.
  • Updated Request.StreamTrimAsync() to accept a StreamTrimMode and include the corresponding keyword in generated XTRIM arguments.
  • Removed the previous unsupported-trim-mode guard from the database stream command path.
  • Updated command argument tests to cover DELREF, ACKED, default behavior, and LIMIT ordering.

Limitations

DELREF and ACKED require Valkey 8.2 or later. The client does not perform a local server-version check; unsupported servers will return the server-side command error.

KeepReferences remains the default mode and is not emitted as KEEPREF to preserve existing behavior and compatibility with older servers.

Testing

Updated unit tests for stream command argument generation.

Ran:

dotnet test tests/Valkey.Glide.UnitTests/Valkey.Glide.UnitTests.csproj --filter "FullyQualifiedName~ValidateStreamCommandArgs"
dotnet test tests/Valkey.Glide.UnitTests/Valkey.Glide.UnitTests.csproj --filter "FullyQualifiedName~ValidateStreamCommandConverters"

Related Issues

Closes #311

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

Copy link
Copy Markdown
Collaborator

Thanks for raising this @Echways.

Unfortunately, the DELREF and ACKED stream trim options have not yet been added to Valkey or the Valkey GLIDE core. There are existing pull requests for adding support for XACKDEL and XDELEX, but not for these options. Until such a time as those are added to Valkey (and then to the Valkey core), I don't think we can support this functionality.

@currantw

currantw commented May 6, 2026

Copy link
Copy Markdown
Collaborator

@Echways I am going to close this pull request. Please feel free to re-open and continue the conversation if I've missed anything!

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.

Add StreamTrimMode.DeleteReferences and Acknowledged support

2 participants