Skip to content

Add key encoding#26

Merged
caleblloyd merged 2 commits intomainfrom
key-encoding
May 25, 2025
Merged

Add key encoding#26
caleblloyd merged 2 commits intomainfrom
key-encoding

Conversation

@caleblloyd
Copy link
Copy Markdown
Contributor

Add Key Encoding to conform with the rules of NATS KV Keys

Caleb Lloyd added 2 commits May 25, 2025 16:21
Signed-off-by: Caleb Lloyd <caleb@boxbuild.io>
Signed-off-by: Caleb Lloyd <caleb@boxbuild.io>
@caleblloyd caleblloyd requested a review from Copilot May 25, 2025 22:19
@caleblloyd caleblloyd changed the title Key encoding Add key encoding May 25, 2025
Copy link
Copy Markdown
Contributor

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

This PR introduces key encoding functionality to ensure keys conform with NATS KV key rules. The key changes include:

  • Adding a new key encoder implementation (NatsCacheKeyEncoder) with corresponding unit tests.
  • Updating NatsCache and its extension registration to utilize the new key encoder.
  • Adjusting logging and error handling in key operations.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/UnitTests/KeyEncoder/NatsCacheKeyEncoderTest.cs Adds comprehensive tests for key encoding and decoding.
src/NatsDistributedCache/NatsDistributedCacheExtensions.cs Updates dependency injection to include the key encoder service.
src/NatsDistributedCache/NatsCacheKeyEncoder.cs Implements the new key encoder that transforms keys to KV-legal forms.
src/NatsDistributedCache/NatsCache.cs Refactors key construction to use the encoded key and removes retry logic.
src/NatsDistributedCache/NatsCache.Log.cs Adjusts logging events and removes the update failure logging.
src/NatsDistributedCache/INatsCacheKeyEncoder.cs Defines the interface for the new key encoder.
Comments suppressed due to low confidence (1)

src/NatsDistributedCache/NatsCache.cs:259

  • The removal of the retry mechanism for handling NatsKVWrongLastRevisionException in GetAndRefreshAsync may impact optimistic concurrency behavior. Consider verifying if this behavior change is intentional or reintroducing a retry strategy to maintain data consistency under concurrent updates.
private async Task<byte[]?> GetAndRefreshAsync(string key, CancellationToken token)

@caleblloyd caleblloyd merged commit 1fc3ce8 into main May 25, 2025
1 check passed
@caleblloyd caleblloyd deleted the key-encoding branch May 25, 2025 22:23
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.

2 participants