Skip to content

Introduce a Token Cache Duration Store#289

Merged
Erwinvandervalk merged 1 commit intomainfrom
pg/hybrid-cache-duration-failure
Oct 28, 2025
Merged

Introduce a Token Cache Duration Store#289
Erwinvandervalk merged 1 commit intomainfrom
pg/hybrid-cache-duration-failure

Conversation

@pgermishuys
Copy link
Copy Markdown
Contributor

@pgermishuys pgermishuys commented Oct 27, 2025

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

@pgermishuys pgermishuys self-assigned this Oct 27, 2025
@pgermishuys pgermishuys added the area/foss/atm Issues related to Access Token Management label Oct 27, 2025
@pgermishuys pgermishuys marked this pull request as ready for review October 27, 2025 12:37
@pgermishuys pgermishuys requested review from a team and Copilot October 27, 2025 12:37
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 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 ClientCredentialsTokenManager into a dedicated singleton store
  • Adds comprehensive test coverage for cache auto-tuning persistence across transient manager instances
  • Enhances test infrastructure with LastOptions tracking in FakeHybridCache

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.

@pgermishuys pgermishuys force-pushed the pg/hybrid-cache-duration-failure branch from d782e0b to 20ba760 Compare October 27, 2025 16:01
This allows us to control the lifetime of the token cache duration
outside of the token manager, which might have conflicting lifetimes.
@Erwinvandervalk Erwinvandervalk merged commit 00552f0 into main Oct 28, 2025
3 checks passed
@Erwinvandervalk Erwinvandervalk deleted the pg/hybrid-cache-duration-failure branch October 28, 2025 06:34
@Erwinvandervalk Erwinvandervalk added this to the atm-4.1.0 milestone Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/foss/atm Issues related to Access Token Management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientCredentialsToken expiration is not applied on second request with UseCacheAutoTuning enabled

3 participants