You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Enable apps to decide what to do when the L2 cache fails (Retry) #1042
Is your feature request related to a problem? Please describe.
Today, when the L2 cache fails, an error is logged, but given the L1 cache was able to proceed, we don't re-throw (think of Redis cache connection error)
Describe the solution you'd like
Have a new property in the MsalDistributedTokenCacheAdapterOptions, so that the application can handle the failure ?
/// <summary>/// Callback offered to the app to be notified when the L2 cache fails./// This way the app is given the possibility to act on the L2 cache,/// for instance, in the case of Redis, to reconnect. This is left to the application as it's/// the only one that knows about the real implementation of the L2 cache./// The handler should return <c>true</c> if the cache should try again the operation, and/// <c>false</c> otherwise. When <c>true</c> is passed and the retry fails, an exception/// will be thrown./// </summary>publicFunc<Exception,bool>?OnL2CacheFailure{get;set;}
Here is an example of how this would be hooked from the Startup.cs:
services.Configure<MsalDistributedTokenCacheAdapterOptions>(options =>{options.L1CacheSizeLimit=10*1024*1024;// 10 Mboptions.OnL2CacheFailure=(ex)=>{if(exisStackExchange.Redis.RedisConnectionException){// Attempt to act on the redis cache if at all possible?// Put here your reconnected codereturntrue;// Retry}returnfalse;// Don't retry.};});
Describe alternatives you've considered
We could also decide of the behavior when it fails again on retry (we could be silent instead of throwing)
changed the title [-][Feature Request] Enable apps to decide what to do when the L2 cache fails[/-][+][Feature Request] Enable apps to decide what to do when the L2 cache fails (Retry)[/+]on Mar 5, 2021
Activity
jmprieur commentedon Mar 4, 2021
Advice from Henrik:
[-][Feature Request] Enable apps to decide what to do when the L2 cache fails[/-][+][Feature Request] Enable apps to decide what to do when the L2 cache fails (Retry)[/+]jmprieur commentedon Mar 8, 2021
Re opening until it's released.
jennyf19 commentedon Mar 10, 2021
Included in 1.8.0 release