Models.Cache.CacheCollection<TKey, TModel> Class
Namespace: Nucleus.Abstractions.Models.Cache
Assembly: Nucleus.Abstractions.dll
Stores a collection of cached entities keys and values. Provides operations to populate and retrieve, remove and clear items the cache.
Type Parameters
TKey |
Key type |
TModel |
Item type |
Constructor
Nucleus.Abstractions.Models.Cache.CacheCollection<TKey, TModel>
Constructor
Nucleus.Abstractions.Models.Cache.CacheCollection<TKey, TModel> (String name, ILogger<ICacheManager> logger, CacheOption options)
Initialize a new instance of the CacheCollection class using the options provided.
Methods
Get
(<TKey,TKey>) Method
Get (<TKey, TKey> itemReader)
Get the item from the cache with the specified key, or if it not present in the cache, read it (using itemReader), add it to the cache and return it.
Parameters
Name |
Type |
key
|
<TKey>
|
itemReader
|
Func<TKey>
|
Returns
The item that matches the specified key.
GetAsync
(<TKey,TKey>) Method
GetAsync (<TKey, TKey> itemReader)
Get the item from the cache with the specified key, or if it not present in the cache, read it (using itemReader), add it to the cache and return it.
Parameters
Name |
Type |
key
|
<TKey>
|
itemReader
|
Func<TKey>
|
Returns
The item that matches the specified key.
Get
(<TKey>) Method
Get (<TKey> key)
Get the item from the cache with the specified key.
Returns
The item with the specified key, or null if it not in the cache, or the cache item has expired.
Add
(<TKey,TModel>) Method
Add (<TKey, TModel> item)
Add the specified key/item to the cache.
Parameters
Name |
Type |
key
|
<TKey>
|
item
|
<TModel>
|
Remove
(<TKey>) Method
Remove (<TKey> key)
Remove an item from the cache, specifed by key.
Clear
Clear ()
Remove all items from the cache.
Collect
Collect ()
Remove expired items from the cache.