Class TransparentCache<TKey, TValue>
Transparently caches retrieval requests, passed through to a callback on first request.
Inherited Members
Namespace: NanoByte.Common.Collections
Assembly: NanoByte.Common.dll
Syntax
public sealed class TransparentCache<TKey, TValue> : TransparentCacheBase<TKey, TValue>
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
TransparentCache(Func<TKey, TValue>)
Transparently caches retrieval requests, passed through to a callback on first request.
Declaration
public TransparentCache(Func<TKey, TValue> retriever)
Parameters
Type | Name | Description |
---|---|---|
Func<TKey, TValue> | retriever | The callback used to retrieve values not yet in the cache. Usually only called once per key. May be called multiple times in multi-threaded scenarios. |
Remarks
This class is thread-safe.
Methods
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 override TValue Retrieve(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key |
Returns
Type | Description |
---|---|
TValue |
Overrides
NanoByte.Common.Collections.TransparentCacheBase<TKey, TValue>.Retrieve(TKey)