Interface ICache<TKey, TValue>
Interface, which describe class for caching data.
Namespace: Kros.Caching
Assembly: Kros.Utils.dll
Syntax
public interface ICache<TKey, TValue>
Type Parameters
Name | Description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
Properties
Count
Gets the count of cached data.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Clear()
Clears the cache.
Declaration
void Clear()
Get(TKey, Func<TValue>)
Gets the cached value by key.
Declaration
TValue Get(TKey key, Func<TValue> factory)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key. |
System.Func<TValue> | factory | The factory for creating value, if doesn't exist in cahce. |
Returns
Type | Description |
---|---|
TValue | Value from Cache. |
Remarks
If value key doesn't exist in cache, then factory is use for creating value and value is set to cache.