put method
void
put(
- K key,
- V value
Puts a value in the cache.
If the cache is full, removes the least recently used item.
Implementation
void put(K key, V value) {
// Remove if exists to update position
_cache.remove(key);
// Evict oldest if at capacity
if (_cache.length >= maxSize) {
_cache.remove(_cache.keys.first);
}
_cache[key] = value;
}