/// <summary> /// Initializes a new instance of the <see cref="AsyncCachePolicyBuilder{TResult}"/> class. /// </summary> /// <param name="isPolicyEnabled">An overall enablement feature flag for enabling/disabling <see cref="AsyncCachePolicy{TResult}"/>.</param> /// <param name="agingStrategy">Cache aging strategy which controls when cache will become stale and expired.</param> /// <param name="cacheProvider">Provides the contract to access cache layer</param> /// <param name="loggingProvider">Provides the contract to logging <see cref="AsyncCachePolicy{TResult}"/> operations</param> internal AsyncCachePolicyBuilder( bool isPolicyEnabled, IAgingStrategy <TResult> agingStrategy, ICacheProvider cacheProvider, ILoggingProvider <TResult> loggingProvider) { cacheProvider.ThrowIfNull(nameof(cacheProvider)); loggingProvider.ThrowIfNull(nameof(loggingProvider)); this.isPolicyEnabled = isPolicyEnabled; this.agingStrategy = agingStrategy; this.cacheProvider = cacheProvider; this.loggingProvider = loggingProvider; }
/// <summary> /// Fluent API to create an instance of <see cref="AsyncCachePolicyBuilder{TResult}"/>. /// </summary> /// <param name="isPolicyEnabled">An overall enablement feature flag for enabling/disabling <see cref="AsyncCachePolicy{TResult}"/>.</param> /// <param name="agingStrategy">Cache aging strategy which controls when cache will become stale and expired.</param> /// <param name="cacheProvider">Provides the contract to access cache layer</param> /// <param name="loggingProvider">Provides the contract to logging <see cref="AsyncCachePolicy{TResult}"/> operations</param> /// <returns>A builder to create <see cref="AsyncCachePolicy{TResult}"/></returns> public static IFallbackConditionStep <TResult> CreateBuilder( bool isPolicyEnabled, IAgingStrategy <TResult> agingStrategy, ICacheProvider cacheProvider, ILoggingProvider <TResult> loggingProvider) { agingStrategy.ThrowIfNull(nameof(agingStrategy)); cacheProvider.ThrowIfNull(nameof(cacheProvider)); loggingProvider.ThrowIfNull(nameof(loggingProvider)); return(new AsyncCachePolicyBuilder <TResult>( isPolicyEnabled, agingStrategy, cacheProvider, loggingProvider)); }