Class SynchronizedMemoizationCacheBase<T, TResult>
Base class for a cache to store memoization entries for a memoized function. Access to the cache gets synchronized through a lock.
Inheritance
Inherited Members
Namespace: System.Memory
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class SynchronizedMemoizationCacheBase<T, TResult> : MemoizationCacheBase<T, TResult>, 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
SynchronizedMemoizationCacheBase()
Declaration
protected SynchronizedMemoizationCacheBase()
Properties
Count
Gets the number of entries in the cache.
Declaration
public override int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Overrides
DebugView
Gets a debug view on the memoization cache.
Declaration
public override string DebugView { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Overrides
SyncRoot
Gets an object to synchronize access to the cache on.
Declaration
protected abstract object SyncRoot { get; }
Property Value
| Type | Description |
|---|---|
| System.Object |
Methods
Clear()
Clears the entries in the cache.
Declaration
public override void Clear()
Overrides
Dispose(Boolean)
Disposes the cache.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing | Indicates whether the dispose operation is triggered by a call to Dispose, or the finalizer. |
Overrides
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 override 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. |