Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use MemoryCache instead of static cache in MSAL#3543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
bgavrilMS wants to merge1 commit intomaster
base:master
Choose a base branch
Loading
frombogavril/3237

Conversation

@bgavrilMS
Copy link
Member

@bgavrilMSbgavrilMS commentedOct 10, 2025
edited
Loading

@jmprieur
Copy link
Collaborator

@jennyf19,@GeoK,@pmaytak
We need to discuss the impact on MISE of this PR: the cache would no longer be static when customer decide InMemoryCache, but it would grow and would require eviction policies.

jennyf19 reacted with thumbs up emoji

@jmprieur
Copy link
Collaborator

Potential Issues for Adopting Services

  1. Cache Behavior Change
    Before: MsalMemoryTokenCacheProvider used MSAL's static shared cache (CacheOptions.EnableSharedCacheOptions)
    After: Uses MemoryCache (ASP.NET Core's IMemoryCache) for token storage
    Impact: Services using in-memory caching may experience different cache isolation characteristics. The static cache was shared across all app instances in the same process, while IMemoryCache provides better scoped isolation.

  2. Memory Management
    Concern: IMemoryCache has different eviction policies compared to MSAL's static cache
    Potential Issue: In high-load scenarios, tokens might be evicted from cache more aggressively, leading to more token acquisitions from the identity provider
    Recommendation: Services should monitor token acquisition patterns and potentially configure MemoryCacheOptions appropriately

  3. Multi-Tenant Scenarios
    Before: The shared static cache could cause issues with cache key collisions across tenants
    After: Better isolation, but services need to ensure their cache configuration supports their multi-tenancy model
    Impact: This is likely a positive change for multi-tenant apps, but services should verify tenant isolation works as expected

  4. Performance
    the In memory cache would be 10x slower than the static cache.@bgavrilMS : do you confirm

@keegan-caruso
Copy link
Contributor

Agree with@jmprieur, it is a large behavioral change, can this be an opt-in behavior?

jennyf19 reacted with thumbs up emoji

@jennyf19
Copy link
Collaborator

We need to discuss the impact on MISE of this PR: the cache would no longer be static when customer decide InMemoryCache, but it would grow and would require eviction policies.

Without eviction policies, we're just trading "static dictionary with predictable growth" for "MemoryCache with unpredictable growth...not an improvement, just a different problem

@bgavrilMS
Copy link
MemberAuthor

bgavrilMS commentedOct 10, 2025
edited
Loading

MSAL static cache

Pros: fast
Cons: no eviction policies and no way to set them

MemoryCache

Pros: app developer can set eviction policies
Cons: slower

If we do opt-in, how would that setting look like?

@jmprieur
Copy link
Collaborator

@bgavrilMS : the recommendation from the MISE team is to add a new boolean in the MicrosoftIdentityApplicationOptions or one of its base classes to specify if to use the static cache or not. An opt-in to use an evictable but slower in-memory cache, making this PR no longer a breaking change.

@pmaytak
Copy link
Contributor

+1 to making this an opt-in change via options. In my experience, different users value different things (cache size vs speed). Setting and changing the default will make someone unhappy. Another point is that when we make big changes like this, even in major versions, it reduces the SDK maintainability a bit. For example, when users have issues, it'll add time to figure out which SDK version has which cache and such. So maybe for now if we keep static cache as default but make it clear on how to change it if size becomes an issue.

@jmprieur
Copy link
Collaborator

jmprieur commentedOct 11, 2025 via email

[like] Jean-Marc Prieur reacted to your message:
________________________________From: Peter ***@***.***>Sent: Saturday, October 11, 2025 7:03:25 AMTo: AzureAD/microsoft-identity-web ***@***.***>Cc: Jean-Marc Prieur ***@***.***>; Mention ***@***.***>Subject: Re: [AzureAD/microsoft-identity-web] Use MemoryCache instead of static cache in MSAL (PR#3543)[https://avatars.githubusercontent.com/u/34331512?s=20&v=4]pmaytak left a comment (AzureAD/microsoft-identity-web#3543)<#3543 (comment)>+1 to making this an opt-in change via options. In my experience, different users value different things (cache size vs speed). Setting and changing the default will make someone unhappy. Another point is that when we make big changes like this, even in major versions, it reduces the SDK maintainability a bit. For example, when users have issues, it'll add time to figure out which SDK version has which cache and such. So maybe for now if we keep static cache as default but make it clear on how to change it if size becomes an issue.—Reply to this email directly, view it on GitHub<#3543 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADEXN5F2YW2BYBJVK7IAW6D3XCTT3AVCNFSM6AAAAACIZEQXJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOJTGAYDGNBUGQ>.You are receiving this because you were mentioned.Message ID: ***@***.***>

@bgavrilMSbgavrilMS marked this pull request as draftOctober 13, 2025 15:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Feature Request- Breaking change] Use an actual MemoryCache with eviction when instructed

6 participants

@bgavrilMS@jmprieur@keegan-caruso@jennyf19@pmaytak

[8]ページ先頭

©2009-2025 Movatter.jp