Table of Contents

Class TransparentCache<TKey, TValue>

Namespace
NanoByte.Common.Collections
Assembly
NanoByte.Common.dll

Transparently caches retrieval requests, passed through to a callback on first request.

public sealed class TransparentCache<TKey, TValue> : TransparentCacheBase<TKey, TValue> where TKey : notnull

Type Parameters

TKey

The type of keys used to request values.

TValue

The type of values returned.

Inheritance
object
TransparentCacheBase<TKey, TValue>
TransparentCache<TKey, TValue>
Inherited Members
Extension Methods

Remarks

This class is thread-safe.

Constructors

TransparentCache(Func<TKey, TValue>)

Transparently caches retrieval requests, passed through to a callback on first request.

public TransparentCache(Func<TKey, TValue> retriever)

Parameters

retriever Func<TKey, TValue>

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.

protected override TValue Retrieve(TKey key)

Parameters

key TKey

Returns

TValue