CachePolicy<TResult>
A cache policy that can be applied to the results of delegate executions.
using Polly.Utilities;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Polly.Caching
{
public class CachePolicy<TResult> : Policy<TResult>, ICachePolicy<TResult>, ICachePolicy, IsPolicy
{
internal CachePolicy(ISyncCacheProvider<TResult> syncCacheProvider, ITtlStrategy<TResult> ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
: base((Func<Func<Context, CancellationToken, TResult>, Context, CancellationToken, TResult>)((Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken) => CacheEngine.Implementation<TResult>(syncCacheProvider, ttlStrategy, cacheKeyStrategy, action, context, cancellationToken, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError)), PredicateHelper.EmptyExceptionPredicates, Enumerable.Empty<ResultPredicate<TResult>>())
{
}
internal CachePolicy(IAsyncCacheProvider<TResult> asyncCacheProvider, ITtlStrategy<TResult> ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
: base((Func<Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken, bool, Task<TResult>>)((Func<Context, CancellationToken, Task<TResult>> func, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) => CacheEngine.ImplementationAsync<TResult>(asyncCacheProvider, ttlStrategy, cacheKeyStrategy, func, context, cancellationToken, continueOnCapturedContext, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError)), PredicateHelper.EmptyExceptionPredicates, Enumerable.Empty<ResultPredicate<TResult>>())
{
}
}
}