Class SerializingCacheProviderAsync<TSerialized>
Defines an IAsyncCacheProvider which serializes objects of any type in and out of an underlying cache which caches as type TSerialized
. For use with asynchronous CachePolicy.
public class SerializingCacheProviderAsync<TSerialized> : IAsyncCacheProvider
Type Parameters
TSerialized
The type of serialized objects to be placed in the cache.
- Inheritance
-
SerializingCacheProviderAsync<TSerialized>
- Implements
- Inherited Members
- Extension Methods
Constructors
SerializingCacheProviderAsync(IAsyncCacheProvider<TSerialized>, ICacheItemSerializer<object, TSerialized>)
Initializes a new instance of the SerializingCacheProviderAsync<TResult, TSerialized> class.
public SerializingCacheProviderAsync(IAsyncCacheProvider<TSerialized> wrappedCacheProvider, ICacheItemSerializer<object, TSerialized> serializer)
Parameters
wrappedCacheProvider
IAsyncCacheProvider<TSerialized>The wrapped cache provider.
serializer
ICacheItemSerializer<object, TSerialized>The serializer.
Exceptions
- ArgumentNullException
wrappedCacheProvider
- ArgumentNullException
serializer
Methods
GetAsync(string, CancellationToken, bool)
Gets a value from the cache asynchronously.
public 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.
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.
public 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.