Class MultiLayerCacheService
Represents a multi-layer caching service that implements the ICacheService interface.
Inherited Members
Namespace: Innovt.Core.Caching
Assembly: Innovt.Core.dll
Syntax
public sealed class MultiLayerCacheService : ICacheService, IDisposable
Remarks
This class provides a caching service that supports multiple caching layers. It allows data retrieval and storage through a series of cache layers, falling back to subsequent layers if data is not found in earlier layers.
Constructors
| Edit this page View SourceMultiLayerCacheService(ICacheService, ICacheService, ILogger)
Initializes a new instance of the MultiLayerCacheService class with multiple caching layers.
Declaration
public MultiLayerCacheService(ICacheService cacheDefaultLayer, ICacheService cacheSecondLayer, ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ICacheService | cacheDefaultLayer | The default caching layer implementing ICacheService. |
ICacheService | cacheSecondLayer | The secondary caching layer implementing ICacheService. |
ILogger | logger | The logger implementation provided by ILogger. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
MultiLayerCacheService(ICacheService, ILogger)
Initializes a new instance of the MultiLayerCacheService class with a default caching layer.
Declaration
public MultiLayerCacheService(ICacheService cacheDefaultLayer, ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ICacheService | cacheDefaultLayer | The default caching layer implementing ICacheService. |
ILogger | logger | The logger implementation provided by ILogger. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
Methods
| Edit this page View SourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
~MultiLayerCacheService()
Finalizes an instance of the MultiLayerCacheService class.
Declaration
protected ~MultiLayerCacheService()
GetValue<T>(string)
Gets the cached value associated with the specified key.
Declaration
public T GetValue<T>(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The unique identifier for the cached item. |
Returns
Type | Description |
---|---|
T | The cached value if found; otherwise, the default value for the type. |
Type Parameters
Name | Description |
---|---|
T | The type of the cached value. |
Remove(string)
Removes a cached value associated with the specified key.
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The unique identifier for the cached item to be removed. |
SetValue<T>(string, T, TimeSpan)
Sets a value in the cache with the specified key and expiration duration.
Declaration
public void SetValue<T>(string key, T entity, TimeSpan expiration)
Parameters
Type | Name | Description |
---|---|---|
string | key | The unique identifier for the cached item. |
T | entity | The value to be cached. |
TimeSpan | expiration | The time duration for which the value should be cached. |
Type Parameters
Name | Description |
---|---|
T | The type of the value to be cached. |