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
TSerializedThe 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
wrappedCacheProviderIAsyncCacheProvider<TSerialized>The wrapped cache provider.
serializerICacheItemSerializer<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
keystringThe cache key.
cancellationTokenCancellationTokenThe cancellation token.
continueOnCapturedContextboolWhether 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
keystringThe cache key.
valueobjectThe value to put into the cache.
ttlTtlThe time-to-live for the cache entry.
cancellationTokenCancellationTokenThe cancellation token.
continueOnCapturedContextboolWhether async calls should continue on a captured synchronization context.