Language
Edit

LeastRecentlyUsedCache<KT,VT>.AddOrUpdateValue(KT, VT, Boolean) Method

Definition

Add or update a value in the cache with associated key.

public void AddOrUpdateValue(KT key, VT value, bool makeNewest = true);
member this.AddOrUpdateValue : 'KT * 'VT * bool -> unit
Public Sub AddOrUpdateValue (key As KT, value As VT, Optional makeNewest As Boolean = true)

Parameters

key
KT

A key associated with the value.

value
VT

The value to add.

makeNewest
Boolean

If true add as the most recently used item. If false, add as oldest item.

Remarks

The key can be used for efficient retrieval of any value, which then makes it the most recently used entry.

If the key already exists, the value is updated and it is moved to the most recently used (newest) slot.

By default it will be positioned as the newest value, but if the makeNewest argument is false, it is also possible to add it as the oldest (and hence first to be reused). This is useful for putting already allocated items back in the list instead of destroying them as a speculative possibility that it MAY get reused in the future even though you're actually done with it for now.

Applies to