Table of Contents

Interface IAsyncCacheProvider

Namespace
Polly.Caching
Assembly
Polly.dll

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 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<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 string

The cache key.

value object

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.