Show / Hide Table of Contents

Class TransparentCache<TKey, TValue>

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

Inheritance
Object
TransparentCacheBase<TKey, TValue>
TransparentCache<TKey, TValue>
Inherited Members
TransparentCacheBase<TKey, TValue>.Retrieve(TKey)
TransparentCacheBase<TKey, TValue>.Remove(TKey)
TransparentCacheBase<TKey, TValue>.Clear()
TransparentCacheBase<TKey, TValue>.Item[TKey]
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>)

Creates a new transparent cache.

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.

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)

Extension Methods

UpdateUtils.To<TIn, TOut>(TIn, Func<TIn, TOut>)
JsonStorage.SaveJson<T>(T, Stream)
JsonStorage.SaveJson<T>(T, String)
JsonStorage.ToJsonString<T>(T)
JsonStorage.ReparseAsJson<T>(Object)
JsonStorage.ReparseAsJson<T>(Object, T)
XmlStorage.SaveXml(Object, Stream, String)
XmlStorage.SaveXml<T>(T, String, String)
XmlStorage.ToXmlString(Object, String)
ConversionUtils.ConvertToString<TType>(TType)
In This Article
Back to top Copyright Bastian Eicher