Interface IAsyncCacheProvider<TResult>
Defines methods for classes providing asynchronous cache functionality for Polly CachePolicy<TResult>s.
public interface IAsyncCacheProvider<TResult>
Type Parameters
TResult
- Extension Methods
Methods
GetAsync(string, CancellationToken, bool)
Gets a value from the cache asynchronously.
Task<TResult> GetAsync(string key, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
keystringThe cache key.
cancellationTokenCancellationTokenThe cancellation token.
continueOnCapturedContextboolWhether async calls should continue on a captured synchronization context.
Note: if the underlying cache's async API does not support controlling whether to continue on a captured context, async Policy executions with continueOnCapturedContext == true cannot be guaranteed to remain on the captured context.
Returns
- Task<TResult>
A Task<TResult> promising as Result the value from cache; or null, if none was found.
PutAsync(string, TResult, Ttl, CancellationToken, bool)
Puts the specified value in the cache asynchronously.
Task PutAsync(string key, TResult value, Ttl ttl, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
keystringThe cache key.
valueTResultThe value to put into the cache.
ttlTtlThe time-to-live for the cache entry.
cancellationTokenCancellationTokenThe cancellation token.
continueOnCapturedContextboolWhether async calls should continue on a captured synchronization context.
Note: if the underlying cache's async API does not support controlling whether to continue on a captured context, async Policy executions with continueOnCapturedContext == true cannot be guaranteed to remain on the captured context.