Table of Contents

Class SerializingCacheProviderAsync<TResult, TSerialized>

Namespace
Polly.Caching
Assembly
Polly.dll

Defines an IAsyncCacheProvider<TResult> which serializes objects of type TResult in and out of an underlying cache which caches as type TSerialized. For use with asynchronous CachePolicy.

public class SerializingCacheProviderAsync<TResult, TSerialized> : IAsyncCacheProvider<TResult>

Type Parameters

TResult

The return type of delegates which may be executed through the policy.

TSerialized

The type of serialized objects to be placed in the cache.

Inheritance
SerializingCacheProviderAsync<TResult, TSerialized>
Implements
Inherited Members
Extension Methods

Constructors

SerializingCacheProviderAsync(IAsyncCacheProvider<TSerialized>, ICacheItemSerializer<TResult, TSerialized>)

Initializes a new instance of the SerializingCacheProviderAsync<TResult, TSerialized> class.

public SerializingCacheProviderAsync(IAsyncCacheProvider<TSerialized> wrappedCacheProvider, ICacheItemSerializer<TResult, TSerialized> serializer)

Parameters

wrappedCacheProvider IAsyncCacheProvider<TSerialized>

The wrapped cache provider.

serializer ICacheItemSerializer<TResult, TSerialized>

The serializer.

Exceptions

ArgumentNullException

wrappedCacheProvider

ArgumentNullException

serializer

Methods

GetAsync(string, CancellationToken, bool)

Gets a value from the cache asynchronously.

public 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.

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.

public 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.

Returns

Task

A Task which completes when the value has been cached.