Class SerializingCacheProvider<TResult, TSerialized>
Defines an ISyncCacheProvider<TResult> which serializes objects of type TResult
in and out of an underlying cache which caches as type TSerialized
. For use with synchronous CachePolicy.
public class SerializingCacheProvider<TResult, TSerialized> : ISyncCacheProvider<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
-
SerializingCacheProvider<TResult, TSerialized>
- Implements
-
ISyncCacheProvider<TResult>
- Inherited Members
- Extension Methods
Constructors
SerializingCacheProvider(ISyncCacheProvider<TSerialized>, ICacheItemSerializer<TResult, TSerialized>)
Initializes a new instance of the SerializingCacheProvider<TResult, TSerialized> class.
public SerializingCacheProvider(ISyncCacheProvider<TSerialized> wrappedCacheProvider, ICacheItemSerializer<TResult, TSerialized> serializer)
Parameters
wrappedCacheProvider
ISyncCacheProvider<TSerialized>The wrapped cache provider.
serializer
ICacheItemSerializer<TResult, TSerialized>The serializer.
Exceptions
- ArgumentNullException
wrappedCacheProvider
- ArgumentNullException
serializer
Methods
Get(string)
Gets a value from the cache.
public TResult Get(string key)
Parameters
key
stringThe cache key.
Returns
- TResult
The value from cache; or null, if none was found.
Put(string, TResult, Ttl)
Puts the specified value in the cache.
public void Put(string key, TResult value, Ttl ttl)