internal override TResult ExecuteInternal <TResult>(Func <Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken) { return(CacheEngine.Implementation <TResult>( _syncCacheProvider.For <TResult>(), _ttlStrategy.For <TResult>(), _cacheKeyStrategy, action, context, cancellationToken, _onCacheGet, _onCacheMiss, _onCachePut, _onCacheGetError, _onCachePutError)); }
/// <summary> /// Executes the specified action asynchronously within the cache policy and returns the result. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="action">The action to perform.</param> /// <param name="context">Execution context that is passed to the exception policy; defines the cache key to use in cache lookup.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="continueOnCapturedContext">Whether to continue on a captured synchronization context.</param> /// <returns>The value returned by the action, or the cache.</returns> public override Task <TResult> ExecuteAsync <TResult>(Func <Context, CancellationToken, Task <TResult> > action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { return(CacheEngine.ImplementationAsync <TResult>( _asyncCacheProvider.AsyncFor <TResult>(), _ttlStrategy, _cacheKeyStrategy, action, context, cancellationToken, continueOnCapturedContext, _onCacheGet, _onCacheMiss, _onCachePut, _onCacheGetError, _onCachePutError)); }
internal override TResult ExecuteInternal <TResult>(Func <Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken) { if (_syncCacheProvider == null) { throw new InvalidOperationException("Please use the synchronous-defined policies when calling the synchronous Execute (and similar) methods."); } return(CacheEngine.Implementation <TResult>( _syncCacheProvider.For <TResult>(), _ttlStrategy.For <TResult>(), _cacheKeyStrategy, action, context, cancellationToken, _onCacheGet, _onCacheMiss, _onCachePut, _onCacheGetError, _onCachePutError)); }
internal override Task <TResult> ExecuteAsyncInternal <TResult>(Func <Context, CancellationToken, Task <TResult> > action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (_asyncCacheProvider == null) { throw new InvalidOperationException("Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods."); } return(CacheEngine.ImplementationAsync <TResult>( _asyncCacheProvider.AsyncFor <TResult>(), _ttlStrategy.For <TResult>(), _cacheKeyStrategy, action, context, cancellationToken, continueOnCapturedContext, _onCacheGet, _onCacheMiss, _onCachePut, _onCacheGetError, _onCachePutError)); }