Interface IDataCache
- Namespace
- FluentCommand
- Assembly
- FluentCommand.dll
An interface for data cache.
public interface IDataCache
Methods
GetAsync<T>(string, CancellationToken)
Gets the specified cache entry from the cache as an object.
Task<(bool Success, T Value)> GetAsync<T>(string key, CancellationToken cancellationToken = default)
Parameters
key
stringA unique identifier for the cache entry.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task<(bool Success, T Value)>
Success is true if the key was found; otherwise false
Value is the cache entry that is identified by key
Type Parameters
T
The type of item in cache
Get<T>(string)
Gets the specified cache entry from the cache as an object.
(bool Success, T Value) Get<T>(string key)
Parameters
key
stringA unique identifier for the cache entry.
Returns
- (bool Success, T Value)
Success is true if the key was found; otherwise false
Value is the cache entry that is identified by key
Type Parameters
T
The type of item in cache
Remove(string)
Removes the cache entry from the cache
void Remove(string key)
Parameters
key
stringA unique identifier for the cache entry.
RemoveAsync(string, CancellationToken)
Removes the cache entry from the cache
Task RemoveAsync(string key, CancellationToken cancellationToken = default)
Parameters
key
stringA unique identifier for the cache entry.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task
A task representing the asynchronous operation.
SetAsync<T>(string, T, DateTimeOffset?, TimeSpan?, CancellationToken)
Inserts a cache entry into the cache, specifying information about how the entry will be evicted.
Task SetAsync<T>(string key, T value, DateTimeOffset? absoluteExpiration = null, TimeSpan? slidingExpiration = null, CancellationToken cancellationToken = default)
Parameters
key
stringA unique identifier for the cache entry.
value
TThe object to insert into cache.
absoluteExpiration
DateTimeOffset?The fixed date and time at which the cache entry will expire.
slidingExpiration
TimeSpan?A value that indicates whether a cache entry should be evicted if it has not been accessed in a given span of time.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task
A task representing the asynchronous operation.
Type Parameters
T
The type of item in cache
Set<T>(string, T, DateTimeOffset?, TimeSpan?)
Inserts a cache entry into the cache, specifying information about how the entry will be evicted.
void Set<T>(string key, T value, DateTimeOffset? absoluteExpiration = null, TimeSpan? slidingExpiration = null)
Parameters
key
stringA unique identifier for the cache entry.
value
TThe object to insert into cache.
absoluteExpiration
DateTimeOffset?The fixed date and time at which the cache entry will expire.
slidingExpiration
TimeSpan?A value that indicates whether a cache entry should be evicted if it has not been accessed in a given span of time.
Type Parameters
T
The type of item in cache