Interface ICacheService
Interface for caching service that provides methods for managing cached data.
Namespace: DataWeb.Data
Assembly: DataWeb.Core.dll
Syntax
public interface ICacheService
Properties
Name
Gets the name of the cache service instance.
Declaration
string Name { get; }
Property Value
Type |
---|
string |
Methods
ClearAsync()
Clears all cached data.
Declaration
Task ClearAsync()
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous clear operation. |
GetAsync<T>(string, Func<Task<T>>, string[], IUser, DateTime?)
Retrieves the cached data associated with the specified key.
Declaration
Task<T> GetAsync<T>(string key, Func<Task<T>> fetchDelegate, string[] dependencies = null, IUser user = null, DateTime? expiration = null)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the cached data to retrieve. |
Func<Task<T>> | fetchDelegate | A function that retrieves the data to cache if it's not already cached. |
string[] | dependencies | An array of dependency keys for the cached data. |
IUser | user | The user associated with the cached data. |
DateTime? | expiration | The expiration time of the cached data. |
Returns
Type | Description |
---|---|
Task<T> | The cached data associated with the specified key. |
Type Parameters
Name | Description |
---|---|
T | The type of the cached data to retrieve. |
GetSectionCacheAsync<T>(string, Func<Task<T>>, string[], IUser, DateTime?)
Retrieves the cached data associated with the specified key and sections.
Declaration
Task<T> GetSectionCacheAsync<T>(string key, Func<Task<T>> fetchDelegate, string[] sections, IUser user = null, DateTime? expiration = null)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the cached data to retrieve. |
Func<Task<T>> | fetchDelegate | A function that retrieves the data to cache if it's not already cached. |
string[] | sections | An array of section names for the cached data. |
IUser | user | The user associated with the cached data. |
DateTime? | expiration | The expiration time of the cached data. |
Returns
Type | Description |
---|---|
Task<T> | The cached data associated with the specified key and sections. |
Type Parameters
Name | Description |
---|---|
T | The type of the cached data to retrieve. |
RemoveAsync(string)
Removes the cached data associated with the specified key.
Declaration
Task RemoveAsync(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the cached data to remove. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous remove operation. |
SetAsync<T>(string, T, string[], DateTime?)
Caches the specified data associated with the specified key.
Declaration
Task SetAsync<T>(string key, T value, string[] dependencies = null, DateTime? expiration = null)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key to associate with the cached data. |
T | value | The data to cache. |
string[] | dependencies | An array of dependency keys for the cached data. |
DateTime? | expiration | The expiration time of the cached data. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous set operation. |
Type Parameters
Name | Description |
---|---|
T | The type of the data to cache. |