Class MemoizationCacheBase<T, TResult>
Base class for a cache to store memoization entries for a memoized function.
Inheritance
System.Object
MemoizationCacheBase<T, TResult>
Inherited Members
Namespace: System.Memory
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class MemoizationCacheBase<T, TResult> : MemoizationCacheBase, IMemoizationCache<T, TResult>, IMemoizationCache, IClearable, IDisposable
Type Parameters
Name | Description |
---|---|
T | Type of the memoized function argument. |
TResult | Type of the memoized function result. |
Constructors
MemoizationCacheBase()
Declaration
protected MemoizationCacheBase()
Methods
GetOrAdd(T)
Gets the result of invoking the memoized function with the specified argument
.
If the memoization cache does not have the result of the function invocation stored yet, it will call the function.
Declaration
public virtual TResult GetOrAdd(T argument)
Parameters
Type | Name | Description |
---|---|---|
T | argument | The argument to get the function invocation result for. |
Returns
Type | Description |
---|---|
TResult | The function invocation result. |
GetOrAddCore(T)
Gets the result of invoking the memoized function with the specified argument
.
If the memoization cache does not have the result of the function invocation stored yet, it will call the function.
Declaration
protected abstract TResult GetOrAddCore(T argument)
Parameters
Type | Name | Description |
---|---|---|
T | argument | The argument to get the function invocation result for. |
Returns
Type | Description |
---|---|
TResult | The function invocation result. |
Implements
System.IDisposable