Class LayeredCache<TKey, TValue>
- Namespace
- Gamelogic.Extensions
- Assembly
- Assembly-CSharp.dll
Represents a cache made out of two layers: a fast primary cache and a slow secondary cache. Things requested that are in the slow cache gets moved to the fast cache, and the oldest item in the fast cache moves to the slow cache.
New things are always added to the primary cache. The oldest item is moved to the slow cache if the primary cache is full.
public class LayeredCache<TKey, TValue> : ICache<TKey, TValue>
Type Parameters
TKeyThe type of the t key.
TValueThe type of the t value.
- Inheritance
-
LayeredCache<TKey, TValue>
- Implements
-
ICache<TKey, TValue>
- Inherited Members
- Extension Methods
Constructors
LayeredCache(int, int)
public LayeredCache(int primaryCapacity, int secondaryCapacity)
Parameters
Properties
Count
Gets the number of elements in the cache .
public int Count { get; }
Property Value
IsFull
Gets a value indicating whether this cache is full.
public bool IsFull { get; }
Property Value
- bool
trueif this cache is full; otherwise,false.
this[TKey]
Gets or sets the value with the specified key. The method ContainsKey should always be called before getting the value of a key.
public TValue this[TKey key] { get; set; }
Parameters
keyTKey
Property Value
- TValue
Methods
ContainsKey(TKey)
Determines whether this cache contains the specified key.
public bool ContainsKey(TKey key)
Parameters
keyTKey
Returns
- bool
trueif the cache contains the key; otherwise,false.
Remove(TKey)
Removes the element at the specified key from the cache.
public TValue Remove(TKey key)
Parameters
keyTKeyThe key.
Returns
- TValue
TValue.
RemoveOldest()
Removes the oldest item from the cache.
public KeyValuePair<TKey, TValue> RemoveOldest()
Returns
- KeyValuePair<TKey, TValue>
KeyValuePair<TKey, TValue>.