Interface ICache<T>
- Namespace
- Duende.IdentityServer.Services
- Assembly
- Duende.IdentityServer.dll
Abstract interface to model data caching
public interface ICache<T> where T : class
Type Parameters
T
The data type to be cached
Methods
GetAsync(string)
Gets the cached data based upon a key index.
Task<T?> GetAsync(string key)
Parameters
key
stringThe key.
Returns
- Task<T>
The cached item, or
null
if no item matches the key.
GetOrAddAsync(string, TimeSpan, Func<Task<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.
Task<T> GetOrAddAsync(string key, TimeSpan duration, Func<Task<T>> get)
Parameters
key
stringThe key.
duration
TimeSpanThe duration.
get
Func<Task<T>>The function to obtain the item.
Returns
- Task<T>
The cached item.
RemoveAsync(string)
Removes the cached data based upon a key index.
Task RemoveAsync(string key)
Parameters
key
stringThe key.
Returns
SetAsync(string, T, TimeSpan)
Caches the data based upon a key
Task SetAsync(string key, T item, TimeSpan expiration)