Class DistributedCache<TCacheItem, TCacheKey>
Inheritance
object
DistributedCache<TCacheItem, TCacheKey>
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Assembly: Volo.Abp.Caching.dll
Syntax
public class DistributedCache<TCacheItem, TCacheKey> : IDistributedCache<TCacheItem, TCacheKey> where TCacheItem : class
Type Parameters
| Name |
Description |
| TCacheItem |
|
| TCacheKey |
|
Constructors
DistributedCache(IOptions<AbpDistributedCacheOptions>, IDistributedCache, ICancellationTokenProvider, IDistributedCacheSerializer, IDistributedCacheKeyNormalizer, IServiceScopeFactory, IUnitOfWorkManager)
Declaration
public DistributedCache(IOptions<AbpDistributedCacheOptions> distributedCacheOption, IDistributedCache cache, ICancellationTokenProvider cancellationTokenProvider, IDistributedCacheSerializer serializer, IDistributedCacheKeyNormalizer keyNormalizer, IServiceScopeFactory serviceScopeFactory, IUnitOfWorkManager unitOfWorkManager)
Parameters
Fields
DefaultCacheOptions
Declaration
protected DistributedCacheEntryOptions DefaultCacheOptions
Field Value
| Type |
Description |
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
|
UowCacheName
Declaration
public const string UowCacheName = "AbpDistributedCache"
Field Value
Properties
Cache
Declaration
protected IDistributedCache Cache { get; }
Property Value
| Type |
Description |
| Microsoft.Extensions.Caching.Distributed.IDistributedCache |
|
CacheName
Declaration
protected string CacheName { get; set; }
Property Value
CancellationTokenProvider
Declaration
protected ICancellationTokenProvider CancellationTokenProvider { get; }
Property Value
IgnoreMultiTenancy
Declaration
protected bool IgnoreMultiTenancy { get; set; }
Property Value
KeyNormalizer
Declaration
protected IDistributedCacheKeyNormalizer KeyNormalizer { get; }
Property Value
Logger
Declaration
public ILogger<DistributedCache<TCacheItem, TCacheKey>> Logger { get; set; }
Property Value
| Type |
Description |
| Microsoft.Extensions.Logging.ILogger<TCategoryName><DistributedCache<TCacheItem, TCacheKey>> |
|
Serializer
Declaration
protected IDistributedCacheSerializer Serializer { get; }
Property Value
ServiceScopeFactory
Declaration
protected IServiceScopeFactory ServiceScopeFactory { get; }
Property Value
| Type |
Description |
| Microsoft.Extensions.DependencyInjection.IServiceScopeFactory |
|
SyncSemaphore
Declaration
protected SemaphoreSlim SyncSemaphore { get; }
Property Value
| Type |
Description |
| System.Threading.SemaphoreSlim |
|
UnitOfWorkManager
Declaration
protected IUnitOfWorkManager UnitOfWorkManager { get; }
Property Value
Methods
Get(TCacheKey, bool?, bool)
Declaration
public virtual TCacheItem Get(TCacheKey key, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
Returns
| Type |
Description |
| TCacheItem |
|
GetAsync(TCacheKey, bool?, bool, CancellationToken)
Declaration
public virtual Task<TCacheItem> GetAsync(TCacheKey key, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task<TResult><TCacheItem> |
|
GetDefaultCacheEntryOptions()
Declaration
protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions()
Returns
| Type |
Description |
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
|
GetMany(IEnumerable<TCacheKey>, bool?, bool)
Declaration
public virtual KeyValuePair<TCacheKey, TCacheItem>[] GetMany(IEnumerable<TCacheKey> keys, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
Returns
| Type |
Description |
| KeyValuePair<TCacheKey, TCacheItem>[] |
|
GetManyAsync(IEnumerable<TCacheKey>, bool?, bool, CancellationToken)
Declaration
public virtual Task<KeyValuePair<TCacheKey, TCacheItem>[]> GetManyAsync(IEnumerable<TCacheKey> keys, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task<TResult><KeyValuePair<TCacheKey, TCacheItem>[]> |
|
GetManyFallback(TCacheKey[], bool?, bool)
Declaration
protected virtual KeyValuePair<TCacheKey, TCacheItem>[] GetManyFallback(TCacheKey[] keys, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| TCacheKey[] |
keys |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
Returns
| Type |
Description |
| KeyValuePair<TCacheKey, TCacheItem>[] |
|
GetManyFallbackAsync(TCacheKey[], bool?, bool, CancellationToken)
Declaration
protected virtual Task<KeyValuePair<TCacheKey, TCacheItem>[]> GetManyFallbackAsync(TCacheKey[] keys, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| TCacheKey[] |
keys |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task<TResult><KeyValuePair<TCacheKey, TCacheItem>[]> |
|
GetOrAdd(TCacheKey, Func<TCacheItem>, Func<DistributedCacheEntryOptions>, bool?, bool)
Declaration
public virtual TCacheItem GetOrAdd(TCacheKey key, Func<TCacheItem> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| System.Func<TResult><TCacheItem> |
factory |
|
| System.Func<TResult><Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions> |
optionsFactory |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
Returns
| Type |
Description |
| TCacheItem |
|
GetOrAddAsync(TCacheKey, Func<Task<TCacheItem>>, Func<DistributedCacheEntryOptions>, bool?, bool, CancellationToken)
Declaration
public virtual Task<TCacheItem> GetOrAddAsync(TCacheKey key, Func<Task<TCacheItem>> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| System.Func<TResult><System.Threading.Tasks.Task<TResult><TCacheItem>> |
factory |
|
| System.Func<TResult><Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions> |
optionsFactory |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task<TResult><TCacheItem> |
|
GetOrAddMany(IEnumerable<TCacheKey>, Func<IEnumerable<TCacheKey>, List<KeyValuePair<TCacheKey, TCacheItem>>>, Func<DistributedCacheEntryOptions>, bool?, bool)
Declaration
public KeyValuePair<TCacheKey, TCacheItem>[] GetOrAddMany(IEnumerable<TCacheKey> keys, Func<IEnumerable<TCacheKey>, List<KeyValuePair<TCacheKey, TCacheItem>>> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| System.Func<T, TResult><System.Collections.Generic.IEnumerable<T><TCacheKey>, System.Collections.Generic.List<T><KeyValuePair<TCacheKey, TCacheItem>>> |
factory |
|
| System.Func<TResult><Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions> |
optionsFactory |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
Returns
| Type |
Description |
| KeyValuePair<TCacheKey, TCacheItem>[] |
|
GetOrAddManyAsync(IEnumerable<TCacheKey>, Func<IEnumerable<TCacheKey>, Task<List<KeyValuePair<TCacheKey, TCacheItem>>>>, Func<DistributedCacheEntryOptions>, bool?, bool, CancellationToken)
Declaration
public Task<KeyValuePair<TCacheKey, TCacheItem>[]> GetOrAddManyAsync(IEnumerable<TCacheKey> keys, Func<IEnumerable<TCacheKey>, Task<List<KeyValuePair<TCacheKey, TCacheItem>>>> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| System.Func<T, TResult><System.Collections.Generic.IEnumerable<T><TCacheKey>, System.Threading.Tasks.Task<TResult><System.Collections.Generic.List<T><KeyValuePair<TCacheKey, TCacheItem>>>> |
factory |
|
| System.Func<TResult><Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions> |
optionsFactory |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task<TResult><KeyValuePair<TCacheKey, TCacheItem>[]> |
|
GetUnitOfWorkCache()
Declaration
protected virtual Dictionary<TCacheKey, UnitOfWorkCacheItem<TCacheItem>> GetUnitOfWorkCache()
Returns
| Type |
Description |
| System.Collections.Generic.Dictionary<TKey, TValue><TCacheKey, UnitOfWorkCacheItem<TCacheItem>> |
|
GetUnitOfWorkCacheKey()
Declaration
protected virtual string GetUnitOfWorkCacheKey()
Returns
HandleException(Exception)
Declaration
protected virtual void HandleException(Exception ex)
Parameters
| Type |
Name |
Description |
| System.Exception |
ex |
|
HandleExceptionAsync(Exception)
Declaration
protected virtual Task HandleExceptionAsync(Exception ex)
Parameters
| Type |
Name |
Description |
| System.Exception |
ex |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
NormalizeKey(TCacheKey)
Declaration
protected virtual string NormalizeKey(TCacheKey key)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
Returns
Refresh(TCacheKey, bool?)
Declaration
public virtual void Refresh(TCacheKey key, bool? hideErrors = null)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| bool? |
hideErrors |
|
RefreshAsync(TCacheKey, bool?, CancellationToken)
Declaration
public virtual Task RefreshAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| bool? |
hideErrors |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
RefreshMany(IEnumerable<TCacheKey>, bool?)
Declaration
public virtual void RefreshMany(IEnumerable<TCacheKey> keys, bool? hideErrors = null)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| bool? |
hideErrors |
|
RefreshManyAsync(IEnumerable<TCacheKey>, bool?, CancellationToken)
Declaration
public virtual Task RefreshManyAsync(IEnumerable<TCacheKey> keys, bool? hideErrors = null, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| bool? |
hideErrors |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
Remove(TCacheKey, bool?, bool)
Declaration
public virtual void Remove(TCacheKey key, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
RemoveAsync(TCacheKey, bool?, bool, CancellationToken)
Declaration
public virtual Task RemoveAsync(TCacheKey key, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
RemoveMany(IEnumerable<TCacheKey>, bool?, bool)
Declaration
public void RemoveMany(IEnumerable<TCacheKey> keys, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
RemoveManyAsync(IEnumerable<TCacheKey>, bool?, bool, CancellationToken)
Declaration
public Task RemoveManyAsync(IEnumerable<TCacheKey> keys, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><TCacheKey> |
keys |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
Set(TCacheKey, TCacheItem, DistributedCacheEntryOptions, bool?, bool)
Declaration
public virtual void Set(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| TCacheItem |
value |
|
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
options |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
SetAsync(TCacheKey, TCacheItem, DistributedCacheEntryOptions, bool?, bool, CancellationToken)
Declaration
public virtual Task SetAsync(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| TCacheKey |
key |
|
| TCacheItem |
value |
|
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
options |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
SetDefaultOptions()
Declaration
protected virtual void SetDefaultOptions()
SetMany(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>>, DistributedCacheEntryOptions, bool?, bool)
Declaration
public void SetMany(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>> items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><KeyValuePair<TCacheKey, TCacheItem>> |
items |
|
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
options |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
SetManyAsync(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>>, DistributedCacheEntryOptions, bool?, bool, CancellationToken)
Declaration
public virtual Task SetManyAsync(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>> items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<T><KeyValuePair<TCacheKey, TCacheItem>> |
items |
|
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
options |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
SetManyFallback(KeyValuePair<TCacheKey, TCacheItem>[], DistributedCacheEntryOptions, bool?, bool)
Declaration
protected virtual void SetManyFallback(KeyValuePair<TCacheKey, TCacheItem>[] items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false)
Parameters
| Type |
Name |
Description |
| KeyValuePair<TCacheKey, TCacheItem>[] |
items |
|
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
options |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
SetManyFallbackAsync(KeyValuePair<TCacheKey, TCacheItem>[], DistributedCacheEntryOptions, bool?, bool, CancellationToken)
Declaration
protected virtual Task SetManyFallbackAsync(KeyValuePair<TCacheKey, TCacheItem>[] items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = default)
Parameters
| Type |
Name |
Description |
| KeyValuePair<TCacheKey, TCacheItem>[] |
items |
|
| Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions |
options |
|
| bool? |
hideErrors |
|
| bool |
considerUow |
|
| System.Threading.CancellationToken |
token |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task |
|
ShouldConsiderUow(bool)
Declaration
protected virtual bool ShouldConsiderUow(bool considerUow)
Parameters
| Type |
Name |
Description |
| bool |
considerUow |
|
Returns
ToCacheItem(byte[])
Declaration
protected virtual TCacheItem ToCacheItem(byte[] bytes)
Parameters
| Type |
Name |
Description |
| byte[] |
bytes |
|
Returns
| Type |
Description |
| TCacheItem |
|
ToCacheItems(byte[][], TCacheKey[])
Declaration
protected virtual KeyValuePair<TCacheKey, TCacheItem>[] ToCacheItems(byte[][] itemBytes, TCacheKey[] itemKeys)
Parameters
| Type |
Name |
Description |
| byte[][] |
itemBytes |
|
| TCacheKey[] |
itemKeys |
|
Returns
| Type |
Description |
| KeyValuePair<TCacheKey, TCacheItem>[] |
|
ToRawCacheItems(KeyValuePair<TCacheKey, TCacheItem>[])
Declaration
protected virtual KeyValuePair<string, byte[]>[] ToRawCacheItems(KeyValuePair<TCacheKey, TCacheItem>[] items)
Parameters
| Type |
Name |
Description |
| KeyValuePair<TCacheKey, TCacheItem>[] |
items |
|
Returns
| Type |
Description |
| KeyValuePair<string, byte[]>[] |
|
Implements
Extension Methods