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
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
context
ContextExecution context that is passed to the exception policy; defines the cache key to use in cache lookup.
cancellationToken
CancellationTokenThe cancellation token.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action, or the cache.
Type Parameters
TResult
The 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
action
Func<Context, CancellationToken, TResult>The action to perform.
context
ContextExecution context that is passed to the exception policy; defines the cache key to use in cache lookup.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- TResult
The value returned by the action, or the cache.
Type Parameters
TResult
The type of the result.