Interface ICacheService
- Namespace
 - FoundationaLLM.Common.Interfaces
 
- Assembly
 - FoundationaLLM.Common.dll
 
Caches objects.
public interface ICacheService
  - Extension Methods
 
Methods
GetItemsCount(string)
Gets the number of items in the cache that belong to a specified category.
int GetItemsCount(string categoryName)
  Parameters
categoryNamestringThe name of the category.
Returns
Get<T>(CacheKey)
Gets an object from the cache.
T? Get<T>(CacheKey key)
  Parameters
Returns
- T
 The object identified by the key.
Type Parameters
TThe type of object retrieved from the cache.
Get<T>(CacheKey, Func<Task<T>>, bool, TimeSpan?)
Gets an object from the cache. If the object is not found in the cache, will attempt to retrieve it using a specified retriever.
Task<T?> Get<T>(CacheKey key, Func<Task<T>> valueRetriever, bool allowNull, TimeSpan? expirationTime)
  Parameters
keyCacheKeyThe CacheKey key identifying the object in the cache.
valueRetrieverFunc<Task<T>>The retriever used to get the value to populate the cache.
allowNullboolIndicates whether null values returned by the value retriever should be cached or not.
expirationTimeTimeSpan?The TimeSpan time to live.
Returns
- Task<T>
 The object identified by the key.
Type Parameters
TThe type of object retrieved from the cache.
Remove(CacheKey)
Removes an object from the cache.
void Remove(CacheKey key)
  Parameters
RemoveByCategory(CacheKey)
Removes all objects belonging to a category from the cache.
void RemoveByCategory(CacheKey key)
  Parameters
Set<T>(CacheKey, T?, TimeSpan?)
Adds an object to the cache.
void Set<T>(CacheKey key, T? value, TimeSpan? expirationTime)
  Parameters
keyCacheKeyThe CacheKey key identifying the object in the cache.
valueTThe object to be added to the cache.
expirationTimeTimeSpan?The TimeSpan time to live.
Type Parameters
TThe type of object retrieved from the cache.