Table of Contents

Interface IAsyncCacheProvider<TResult>

Namespace
Polly.Caching
Assembly
Polly.dll

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

key string

The cache key.

cancellationToken CancellationToken

The cancellation token.

continueOnCapturedContext bool

Whether 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

key string

The cache key.

value TResult

The value to put into the cache.

ttl Ttl

The time-to-live for the cache entry.

cancellationToken CancellationToken

The cancellation token.

continueOnCapturedContext bool

Whether 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

A Task which completes when the value has been cached.