Interface IAsyncCacheProvider
Defines methods for classes providing asynchronous cache functionality for Polly CachePolicys.
public interface IAsyncCacheProvider
- Extension Methods
Methods
GetAsync(string, CancellationToken, bool)
Gets a value from the cache asynchronously.
Task<object> GetAsync(string key, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
key
stringThe cache key.
cancellationToken
CancellationTokenThe cancellation token.
continueOnCapturedContext
boolWhether 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<object>
A Task<TResult> promising as Result the value from cache; or null, if none was found.
PutAsync(string, object, Ttl, CancellationToken, bool)
Puts the specified value in the cache asynchronously.
Task PutAsync(string key, object value, Ttl ttl, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
key
stringThe cache key.
value
objectThe value to put into the cache.
ttl
TtlThe time-to-live for the cache entry.
cancellationToken
CancellationTokenThe cancellation token.
continueOnCapturedContext
boolWhether 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.