Introduce a Token Cache Duration Store#289
Merged
Erwinvandervalk merged 1 commit intomainfrom Oct 28, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a ClientCredentialsCacheDurationStore to manage token cache duration state separately from the transient ClientCredentialsTokenManager, ensuring cache auto-tuning persists across manager instances.
- Extracts cache duration auto-tuning logic from
ClientCredentialsTokenManagerinto a dedicated singleton store - Adds comprehensive test coverage for cache auto-tuning persistence across transient manager instances
- Enhances test infrastructure with
LastOptionstracking inFakeHybridCache
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ClientCredentialsCacheDurationStore.cs | New singleton store managing cache duration state with auto-tuning logic |
| ClientCredentialsTokenManager.cs | Refactored to delegate cache duration management to the new store |
| ServiceCollectionExtensions.cs | Registers the new cache duration store as a singleton service |
| ClientTokenManagementTests.cs | Adds test verifying cache auto-tuning persists across manager instances |
| FakeHybridCache.cs | Enhanced to track last used cache options for testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
access-token-management/test/AccessTokenManagement.Tests/ClientTokenManagementTests.cs
Outdated
Show resolved
Hide resolved
access-token-management/src/AccessTokenManagement/Internal/ClientCredentialsTokenManager.cs
Outdated
Show resolved
Hide resolved
d782e0b to
20ba760
Compare
Erwinvandervalk
previously approved these changes
Oct 27, 2025
This allows us to control the lifetime of the token cache duration outside of the token manager, which might have conflicting lifetimes.
20ba760 to
36a4180
Compare
Erwinvandervalk
approved these changes
Oct 28, 2025
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.
We are pulling out the cache duration storage from the token manager by introducing a new service and registering that as a singleton.
This allows us to control the lifetime of the token cache duration outside of the token manager, which might have conflicting lifetimes.
What issue does this PR address?
Fixes #287