NanoByte.Common  2.6.1
NanoByte.Common.Collections.TransparentCache< TKey, TValue > Class Template Reference

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

Inheritance diagram for NanoByte.Common.Collections.TransparentCache< TKey, TValue >:
NanoByte.Common.Collections.TransparentCacheBase< TKey, TValue >

Public Member Functions

 TransparentCache (Func< TKey, TValue > retriever)
 Creates a new transparent cache. More...
 
- Public Member Functions inherited from NanoByte.Common.Collections.TransparentCacheBase< TKey, TValue >
bool Remove (TKey key)
 Removes the the entry with the specified key from the cache. More...
 
void Clear ()
 Removes all entries from the cache. More...
 

Protected Member Functions

override TValue Retrieve (TKey key)
 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.
 

Additional Inherited Members

- Properties inherited from NanoByte.Common.Collections.TransparentCacheBase< TKey, TValue >
TValue this[TKey key] [get]
 Retrieves a value from the cache. More...
 

Detailed Description

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

This class is thread-safe.

Template Parameters
TKeyThe type of keys used to request values.
TValueThe type of values returned.
Type Constraints
TKey :notnull 

Constructor & Destructor Documentation

◆ TransparentCache()

NanoByte.Common.Collections.TransparentCache< TKey, TValue >.TransparentCache ( Func< TKey, TValue >  retriever)
inline

Creates a new transparent cache.

Parameters
retrieverThe 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.

The documentation for this class was generated from the following file: