Interface IDistributedCache<TCacheItem, TCacheKey>
Represents a distributed cache of TCacheItem
type.
Uses a generic cache key type of TCacheKey
type.
Namespace: Volo.Abp.Caching
Assembly: Volo.Abp.Caching.dll
Syntax
public interface IDistributedCache<TCacheItem, TCacheKey>
where TCacheItem : class
Type Parameters
Name | Description |
---|---|
TCacheItem | The type of cache item being cached. |
TCacheKey | The type of cache key being used. |
Methods
Get(TCacheKey, Nullable<Boolean>, Boolean)
Gets a cache item with the given key. If no cache item is found for the given key then returns null.
Declaration
TCacheItem Get(TCacheKey key, bool? hideErrors = null, bool considerUow = false)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
Returns
Type | Description |
---|---|
TCacheItem | The cache item, or null. |
GetAsync(TCacheKey, Nullable<Boolean>, Boolean, CancellationToken)
Gets a cache item with the given key. If no cache item is found for the given key then returns null.
Declaration
Task<TCacheItem> GetAsync(TCacheKey key, bool? hideErrors = null, bool considerUow = false, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
CancellationToken | token | The System.Threading.CancellationToken for the task. |
Returns
Type | Description |
---|---|
Task<TCacheItem> | The cache item, or null. |
GetMany(IEnumerable<TCacheKey>, Nullable<Boolean>, Boolean)
Gets multiple cache items with the given keys.
The returned list contains exactly the same count of items specified in the given keys. An item in the return list can not be null, but an item in the list has null value if the related key not found in the cache.
Declaration
KeyValuePair<TCacheKey, TCacheItem>[] GetMany(IEnumerable<TCacheKey> keys, bool? hideErrors = null, bool considerUow = false)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TCacheKey> | keys | The keys of cached items to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
Returns
Type | Description |
---|---|
KeyValuePair<TCacheKey, TCacheItem>[] | List of cache items. |
GetManyAsync(IEnumerable<TCacheKey>, Nullable<Boolean>, Boolean, CancellationToken)
Gets multiple cache items with the given keys.
The returned list contains exactly the same count of items specified in the given keys. An item in the return list can not be null, but an item in the list has null value if the related key not found in the cache.
Declaration
Task<KeyValuePair<TCacheKey, TCacheItem>[]> GetManyAsync(IEnumerable<TCacheKey> keys, bool? hideErrors = null, bool considerUow = false, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TCacheKey> | keys | The keys of cached items to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
CancellationToken | token | The System.Threading.CancellationToken for the task. |
Returns
Type | Description |
---|---|
Task<KeyValuePair<TCacheKey, TCacheItem>[]> | List of cache items. |
GetOrAdd(TCacheKey, Func<TCacheItem>, Func<DistributedCacheEntryOptions>, Nullable<Boolean>, Boolean)
Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item
provided by factory
delegate and returns the provided cache item.
Declaration
TCacheItem GetOrAdd(TCacheKey key, Func<TCacheItem> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
Func<TCacheItem> | factory | The factory delegate is used to provide the cache item when no cache item is found for the given |
Func<DistributedCacheEntryOptions> | optionsFactory | The cache options for the factory delegate. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
Returns
Type | Description |
---|---|
TCacheItem | The cache item. |
GetOrAddAsync(TCacheKey, Func<Task<TCacheItem>>, Func<DistributedCacheEntryOptions>, Nullable<Boolean>, Boolean, CancellationToken)
Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item
provided by factory
delegate and returns the provided cache item.
Declaration
Task<TCacheItem> GetOrAddAsync(TCacheKey key, Func<Task<TCacheItem>> factory, Func<DistributedCacheEntryOptions> optionsFactory = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
Func<Task<TCacheItem>> | factory | The factory delegate is used to provide the cache item when no cache item is found for the given |
Func<DistributedCacheEntryOptions> | optionsFactory | The cache options for the factory delegate. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
CancellationToken | token | The System.Threading.CancellationToken for the task. |
Returns
Type | Description |
---|---|
Task<TCacheItem> | The cache item. |
Refresh(TCacheKey, Nullable<Boolean>)
Refreshes the cache value of the given key, and resets its sliding expiration timeout.
Declaration
void Refresh(TCacheKey key, bool? hideErrors = null)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
RefreshAsync(TCacheKey, Nullable<Boolean>, CancellationToken)
Refreshes the cache value of the given key, and resets its sliding expiration timeout.
Declaration
Task RefreshAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
CancellationToken | token | The System.Threading.CancellationToken for the task. |
Returns
Type | Description |
---|---|
Task | The System.Threading.Tasks.Task indicating that the operation is asynchronous. |
Remove(TCacheKey, Nullable<Boolean>, Boolean)
Removes the cache item for given key from cache.
Declaration
void Remove(TCacheKey key, bool? hideErrors = null, bool considerUow = false)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
RemoveAsync(TCacheKey, Nullable<Boolean>, Boolean, CancellationToken)
Removes the cache item for given key from cache.
Declaration
Task RemoveAsync(TCacheKey key, bool? hideErrors = null, bool considerUow = false, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
CancellationToken | token | The System.Threading.CancellationToken for the task. |
Returns
Type | Description |
---|---|
Task | The System.Threading.Tasks.Task indicating that the operation is asynchronous. |
Set(TCacheKey, TCacheItem, DistributedCacheEntryOptions, Nullable<Boolean>, Boolean)
Sets the cache item value for the provided key.
Declaration
void Set(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
TCacheItem | value | The cache item value to set in the cache. |
DistributedCacheEntryOptions | options | The cache options for the value. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
SetAsync(TCacheKey, TCacheItem, DistributedCacheEntryOptions, Nullable<Boolean>, Boolean, CancellationToken)
Sets the cache item value for the provided key.
Declaration
Task SetAsync(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
TCacheKey | key | The key of cached item to be retrieved from the cache. |
TCacheItem | value | The cache item value to set in the cache. |
DistributedCacheEntryOptions | options | The cache options for the value. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
CancellationToken | token | The System.Threading.CancellationToken for the task. |
Returns
Type | Description |
---|---|
Task | The System.Threading.Tasks.Task indicating that the operation is asynchronous. |
SetMany(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>>, DistributedCacheEntryOptions, Nullable<Boolean>, Boolean)
Sets multiple cache items. Based on the implementation, this can be more efficient than setting multiple items individually.
Declaration
void SetMany(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>> items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TCacheKey, TCacheItem>> | items | Items to set on the cache |
DistributedCacheEntryOptions | options | The cache options for the value. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
SetManyAsync(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>>, DistributedCacheEntryOptions, Nullable<Boolean>, Boolean, CancellationToken)
Sets multiple cache items. Based on the implementation, this can be more efficient than setting multiple items individually.
Declaration
Task SetManyAsync(IEnumerable<KeyValuePair<TCacheKey, TCacheItem>> items, DistributedCacheEntryOptions options = null, bool? hideErrors = null, bool considerUow = false, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TCacheKey, TCacheItem>> | items | Items to set on the cache |
DistributedCacheEntryOptions | options | The cache options for the value. |
System.Nullable<System.Boolean> | hideErrors | Indicates to throw or hide the exceptions for the distributed cache. |
System.Boolean | considerUow | This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache. |
CancellationToken | token | The System.Threading.CancellationToken for the task. |
Returns
Type | Description |
---|---|
Task | The System.Threading.Tasks.Task indicating that the operation is asynchronous. |