Class CachePolicy
A cache policy that can be applied to the results of delegate executions.
public class CachePolicy : Policy, ISyncPolicy, IAsyncPolicy, ICachePolicy, IsPolicy
- Inheritance
-
CachePolicy
- Implements
- Inherited Members
Methods
ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken, bool)
Executes the specified action asynchronously within the cache policy and returns the result.
public override Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextContextExecution context that is passed to the exception policy; defines the cache key to use in cache lookup.
cancellationTokenCancellationTokenThe cancellation token.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action, or the cache.
Type Parameters
TResultThe type of the result.
Execute<TResult>(Func<Context, CancellationToken, TResult>, Context, CancellationToken)
Executes the specified action within the cache policy and returns the result.
public override TResult Execute<TResult>(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
Parameters
actionFunc<Context, CancellationToken, TResult>The action to perform.
contextContextExecution context that is passed to the exception policy; defines the cache key to use in cache lookup.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- TResult
The value returned by the action, or the cache.
Type Parameters
TResultThe type of the result.