Class TransparentCacheBase<TKey, TValue>
Transparently caches retrieval requests, passed through to a template method on first request.
Namespace: NanoByte.Common.Collections
Assembly: NanoByte.Common.dll
Syntax
public abstract class TransparentCacheBase<TKey, TValue> : Object
Type Parameters
Name | Description |
---|---|
TKey | The type of keys used to request values. |
TValue | The type of values returned. |
Remarks
This class is thread-safe.
Constructors
TransparentCacheBase()
Declaration
protected TransparentCacheBase()
Properties
Item[TKey]
Retrieves a value from the cache.
Declaration
public TValue this[TKey key] { get; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key |
Property Value
Type | Description |
---|---|
TValue |
Methods
Clear()
Removes all entries from the cache.
Declaration
public void Clear()
Remove(TKey)
Removes the the entry with the specified key
from the cache.
Declaration
public bool Remove(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key |
Returns
Type | Description |
---|---|
Boolean |
|
Retrieve(TKey)
Template method used to retrieve values not yet in the cache. Usually only called once per key. May be called multiple times in multi-threaded scenarios.
Declaration
protected abstract TValue Retrieve(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key |
Returns
Type | Description |
---|---|
TValue |