AliBazzi / IdentityServer4.Contrib.RedisStore

A persistence layer using Redis DB for operational data and for caching capability for Identity Server 4
https://www.nuget.org/packages/IdentityServer4.Contrib.RedisStore
MIT License
137 stars 48 forks source link

Add an option to the ProfileServiceCache to opt in caching based on certain criteria #29

Closed AliBazzi closed 4 years ago

AliBazzi commented 4 years ago

When use Profile Service Caching, we may have cases where the caching decision would be made based on certain criteria.

A proposal is to add a new option would be added to ProfileServiceCachingOptions as:

public class ProfileServiceCachingOptions<T>
        where T : class, IProfileService
    {
        .....

        ///<summary>
        /// A predicate that will determine whether the current ActiveContext should be cached or not, default to true on all IsActiveContext instances.
        /// </summary>
        public Func<IsActiveContext, bool> ShouldCache { get; set; } = (context) => true;

        .....
    }