Interface ICache<T>
Abstract interface to model data caching
Namespace: IRM.Caching
Assembly: IRM.dll
Syntax
public interface ICache<T>
where T : class
Type Parameters
T
|
Methods
Get(String)
Gets the cached data based upon a key index.
Declaration
T Get(string key)
Parameters
String
key
The key. |
Returns
T
The cached item, or |
GetAsync(String, CancellationToken)
Gets the cached data based upon a key index.
Declaration
Task<T> GetAsync(string key, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
key
The key. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<T>
The cached item, or |
GetOrAdd(String, TimeSpan, Func<T>)
Gets the cached data based upon a key index.
If the item is not found, the get
function is used to obtain the item and populate the cache.
Declaration
T GetOrAdd(string key, TimeSpan duration, Func<T> get)
Parameters
String
key
The key. |
TimeSpan
duration
The duration. |
System.Func<T>
get
The function to obtain the item. |
Returns
T
The cached item. |
GetOrAddAsync(String, TimeSpan, Func<CancellationToken, Task<T>>, CancellationToken)
Gets the cached data based upon a key index.
If the item is not found, the get
function is used to obtain the item and populate the cache.
Declaration
Task<T> GetOrAddAsync(string key, TimeSpan duration, Func<CancellationToken, Task<T>> get, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
key
The key. |
TimeSpan
duration
The duration. |
System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<T>>
get
The function to obtain the item. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<T>
The cached item. |
RemoveAsync(String, CancellationToken)
Removes the cached data based upon a key index.
Declaration
Task RemoveAsync(string key, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
key
The key. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task
|
Set(String, T, TimeSpan)
Caches the data based upon a key
Declaration
void Set(string key, T item, TimeSpan expiration)
Parameters
String
key
The key. |
T
item
The item. |
TimeSpan
expiration
The expiration. |
SetAsync(String, T, TimeSpan, CancellationToken)
Caches the data based upon a key
Declaration
Task SetAsync(string key, T item, TimeSpan expiration, CancellationToken cancellationToken = default(CancellationToken))
Parameters
String
key
The key. |
T
item
The item. |
TimeSpan
expiration
The expiration. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task
|