Show / Hide Table of Contents

Class TransparentCacheBase<TKey, TValue>

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

Inheritance
Object
TransparentCacheBase<TKey, TValue>
TransparentCache<TKey, TValue>
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

true if a matching entry was found and removed; false if no matching entry was in the cache.

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

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