Class DistributedCacheHandler<TCache>
- Namespace
- Apizr
- Assembly
- Apizr.Extensions.Microsoft.Caching.dll
Distributed cache handler implementation
public class DistributedCacheHandler<TCache> : ICacheHandler
Type Parameters
TCache
- Inheritance
-
DistributedCacheHandler<TCache>
- Implements
- Inherited Members
Constructors
DistributedCacheHandler(IDistributedCache, IHttpContentSerializer)
public DistributedCacheHandler(IDistributedCache distributedCache, IHttpContentSerializer contentSerializer)
Parameters
distributedCache
IDistributedCachecontentSerializer
IHttpContentSerializer
Methods
ClearAsync(CancellationToken)
Map Apizr cache clearing method to your cache handler method
public Task ClearAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAn optional cancellation token
Returns
GetAsync<TData>(string, CancellationToken)
Map Apizr cache getting method to your cache handler method
public Task<TData> GetAsync<TData>(string key, CancellationToken cancellationToken = default)
Parameters
key
stringThe key to get from
cancellationToken
CancellationTokenAn optional cancellation token
Returns
- Task<TData>
Type Parameters
TData
RemoveAsync(string, CancellationToken)
Map Apizr cache removing method to your cache handler method
public Task<bool> RemoveAsync(string key, CancellationToken cancellationToken = default)
Parameters
key
stringThe key to remove from
cancellationToken
CancellationTokenAn optional cancellation token
Returns
SetAsync(string, object, TimeSpan?, CancellationToken)
Map Apizr cache saving method to your cache handler method
public Task SetAsync(string key, object value, TimeSpan? lifeSpan = null, CancellationToken cancellationToken = default)
Parameters
key
stringThe key to cache at
value
objectThe value to cache
lifeSpan
TimeSpan?The optional life span
cancellationToken
CancellationTokenAn optional cancellation token