CachePolicy<TResult>
A cache policy that can be applied to the results of delegate executions.
            
                using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Polly.Caching
{
    [System.Runtime.CompilerServices.NullableContext(1)]
    [System.Runtime.CompilerServices.Nullable(new byte[] {
        0,
        1
    })]
    public class CachePolicy<[System.Runtime.CompilerServices.Nullable(2)] TResult> : Policy<TResult>, ICachePolicy<TResult>, ICachePolicy, IsPolicy
    {
        private readonly Action<Context, string> _onCacheGet;
        private readonly Action<Context, string> _onCacheMiss;
        private readonly Action<Context, string> _onCachePut;
        [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            1,
            1,
            1
        })]
        private readonly Action<Context, string, Exception> _onCacheGetError;
        [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            1,
            1,
            1
        })]
        private readonly Action<Context, string, Exception> _onCachePutError;
        private readonly ISyncCacheProvider<TResult> _syncCacheProvider;
        private readonly ITtlStrategy<TResult> _ttlStrategy;
        private readonly Func<Context, string> _cacheKeyStrategy;
        internal CachePolicy(ISyncCacheProvider<TResult> syncCacheProvider, ITtlStrategy<TResult> ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            1,
            1,
            1
        })] Action<Context, string, Exception> onCacheGetError, [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            1,
            1,
            1
        })] Action<Context, string, Exception> onCachePutError)
            : base((PolicyBuilder<TResult>)null)
        {
            _syncCacheProvider = syncCacheProvider;
            _ttlStrategy = ttlStrategy;
            _cacheKeyStrategy = cacheKeyStrategy;
            _onCacheGet = onCacheGet;
            _onCachePut = onCachePut;
            _onCacheMiss = onCacheMiss;
            _onCacheGetError = onCacheGetError;
            _onCachePutError = onCachePutError;
        }
        [DebuggerStepThrough]
        protected override TResult Implementation(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
        {
            if (action == null)
                throw new ArgumentNullException("action");
            return CacheEngine.Implementation<TResult>(_syncCacheProvider, _ttlStrategy, _cacheKeyStrategy, action, context, _onCacheGet, _onCacheMiss, _onCachePut, _onCacheGetError, _onCachePutError, cancellationToken);
        }
    }
}