Class CacheExtensions
Extensions methods for ICache
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: IRM.Extensions.Caching
Assembly: IRM.Extensions.Caching.dll
Syntax
public static class CacheExtensions
Methods
GetOrCreateAsync<TItem>(ICache, String, Func<CacheEntryOptions, Task<TItem>>, CancellationToken)
Tries to get an specific item from the cache, if it's not found the factory is used to create it.
Declaration
public static async Task<TItem> GetOrCreateAsync<TItem>(this ICache cache, string key, Func<CacheEntryOptions, Task<TItem>> factory, CancellationToken cancellationToken = default(CancellationToken))
where TItem : class
Parameters
|
ICache
cache
The ICache objekt. |
|
String
key
A string identifying the requested value. |
|
System.Func<CacheEntryOptions, System.Threading.Tasks.Task<TItem>>
factory
Factory method used to create the item to be stored in the cache. |
|
System.Threading.CancellationToken
cancellationToken
Optional, the System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
|
System.Threading.Tasks.Task<TItem>
The item found in the cache or if it's not found the item created by the |
Type Parameters
|
TItem
The type of the item. |