Skip to content

Update cache check#591

Merged
linglingye001 merged 1 commit intomainfrom
linglingye/update-cache-check
Apr 16, 2026
Merged

Update cache check#591
linglingye001 merged 1 commit intomainfrom
linglingye/update-cache-check

Conversation

@linglingye001
Copy link
Copy Markdown
Member

Why this PR?

Problem

The IFeatureDefinitionProviderCacheable interface in IFeatureDefinitionProviderCacheable.cs is internal, which prevents anyone implementing a custom IFeatureDefinitionProvider from opting into the filter parameter binding cache — a performance optimization that avoids expensive IConfiguration.Get<T>() calls on every evaluation. #367

How the Caching Works Today

if (!(_featureDefinitionProvider is IFeatureDefinitionProviderCacheable) || Cache == null)

If the provider does not implement the internal marker interface, filter parameter binding (the binder.BindParameters(context.Parameters) call) runs on every evaluation — no caching. The ConfigurationWrapper class enables cache invalidation by creating a new reference when configuration changes, so cacheItem.Parameters != context.Parameters detects staleness.

Visible Changes

Update the cache check in FeatureManager to also recognize ConfigurationWrapper-based parameters, so wrappers around ConfigurationFeatureDefinitionProvider automatically get caching without any API changes. For fully custom providers, PR #589 is being worked on to let providers supply FeatureDefinition objects directly (bypassing the configuration layer entirely), which would make the caching question moot.

Comment thread tests/Tests.FeatureManagement/FeatureManagementTest.cs
@linglingye001 linglingye001 force-pushed the linglingye/update-cache-check branch from 230e8f2 to de96c35 Compare April 16, 2026 05:17
@linglingye001 linglingye001 merged commit 46aa3de into main Apr 16, 2026
5 checks passed
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.

3 participants