Interface ITaskCache
- Namespace
- GreenDonut
- Assembly
- GreenDonut.dll
A memorization cache for DataLoader
.
public interface ITaskCache
Properties
Size
Gets the maximum size of the cache.
int Size { get; }
Property Value
Usage
Gets the count of the entries inside the cache.
int Usage { get; }
Property Value
Methods
Clear()
Clears the complete cache.
void Clear()
GetOrAddTask<T>(TaskCacheKey, Func<T>)
Gets a task from the cache if a task with the specified key
already
exists; otherwise, the createTask
factory is used to create a new
task and add it to the cache.
T GetOrAddTask<T>(TaskCacheKey key, Func<T> createTask) where T : Task
Parameters
key
TaskCacheKeyA cache entry key.
createTask
Func<T>A factory to create the new task.
Returns
- T
Returns either the retrieved or new task from the cache.
Type Parameters
T
The task type.
Exceptions
- ArgumentNullException
Throws if
key
isnull
.- ArgumentNullException
Throws if
createTask
isnull
.
TryAdd<T>(TaskCacheKey, Func<T>)
Tries to add a single task to the cache. It does nothing if the task exists already.
bool TryAdd<T>(TaskCacheKey key, Func<T> createTask) where T : Task
Parameters
key
TaskCacheKeyA cache entry key.
createTask
Func<T>A factory to create the new task.
Returns
- bool
A value indicating whether the add was successful.
Type Parameters
T
The task type.
Exceptions
- ArgumentNullException
Throws if
key
isnull
.- ArgumentNullException
Throws if
createTask
isnull
.
TryAdd<T>(TaskCacheKey, T)
Tries to add a single task to the cache. It does nothing if the task exists already.
bool TryAdd<T>(TaskCacheKey key, T value) where T : Task
Parameters
key
TaskCacheKeyA cache entry key.
value
TA task.
Returns
- bool
A value indicating whether the add was successful.
Type Parameters
T
The task type.
Exceptions
- ArgumentNullException
Throws if
key
isnull
.- ArgumentNullException
Throws if
value
isnull
.
TryRemove(TaskCacheKey)
Removes a specific task from the cache.
bool TryRemove(TaskCacheKey key)
Parameters
key
TaskCacheKeyA cache entry key.
Returns
Exceptions
- ArgumentNullException
Throws if
key
isnull
.