put method

void put(
  1. K key,
  2. V value
)

Inserts or updates key with value. When the cache is full and key is new, the most-recently-used entry is evicted to make room. Audited: 2026-06-12 11:26 EDT

Implementation

void put(K key, V value) {
  if (!_values.containsKey(key) && _values.length >= _capacity) _evictMru();
  _values[key] = value;
  _touch(key);
}