Class LruCache<TKey, TValue>
A cache implementation that uses the least recently used (LRU) policy to evict stale key-value pairs.
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Flame.Collections
Assembly: Flame.dll
Syntax
public sealed class LruCache<TKey, TValue> : Cache<TKey, TValue>
Type Parameters
Name | Description |
---|---|
TKey | |
TValue |
Constructors
| Improve this Doc View SourceLruCache(Int32)
Creates an LRU cache with a particular capacity.
Declaration
public LruCache(int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | The maximal number of key-value pairs in the LRU cache. |
LruCache(Int32, IEqualityComparer<TKey>)
Creates an LRU cache with a particular capacity and a key equality comparer.
Declaration
public LruCache(int capacity, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | The maximal number of key-value pairs in the LRU cache. |
System.Collections.Generic.IEqualityComparer<TKey> | comparer | An equality comparer for keys. |
Properties
| Improve this Doc View SourceCapacity
Gets the LRU cache's capacity.
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The maximal number of key-value pairs in the LRU cache. |
Methods
| Improve this Doc View SourceGet(TKey, Func<TKey, TValue>)
Declaration
public override TValue Get(TKey key, Func<TKey, TValue> createValue)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | |
System.Func<TKey, TValue> | createValue |
Returns
Type | Description |
---|---|
TValue |
Overrides
Flame.Collections.Cache<TKey, TValue>.Get(TKey, System.Func<TKey, TValue>)
|
Improve this Doc
View Source
Insert(TKey, TValue)
Declaration
public override void Insert(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | |
TValue | value |
Overrides
Flame.Collections.Cache<TKey, TValue>.Insert(TKey, TValue)
|
Improve this Doc
View Source
TryGet(TKey, out TValue)
Declaration
public override bool TryGet(TKey key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | |
TValue | value |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Flame.Collections.Cache<TKey, TValue>.TryGet(TKey, TValue)