public Cache(
Func<TKey, TValue>? itemLoader,
IEqualityComparer<TKey>? comparer
)
Public Sub New (
itemLoader As Func(Of TKey, TValue),
comparer As IEqualityComparer(Of TKey)
)
public:
Cache(
Func<TKey, TValue>^ itemLoader,
IEqualityComparer<TKey>^ comparer
)
new :
itemLoader : Func<'TKey, 'TValue> *
comparer : IEqualityComparer<'TKey> -> Cache
Every key in a CacheTKey, TValue must be unique according to the specified comparer.
When CacheTKey, TValue is full (that is, when Count reaches Capacity) and a new element is about to be stored, then an element will be dropped out from the cache. The strategy is controlled by Behavior property.
If you want to add elements manually to the CacheTKey, TValue, then you can pass to the itemLoader parameter. In this case the CacheTKey, TValue can be used similarly to a DictionaryTKey, TValue: before getting an element, its existence must be checked by ContainsKey or TryGetValue methods, though Capacity is still maintained based on the strategy specified in the Behavior property.