get method

V? get(
  1. K key
)

Returns the value for key (or null), counting the access and marking the key most-recently-used.

Example:

final MruCache<String, int> c = MruCache<String, int>(2)
  ..put('a', 1)
  ..put('b', 2);
c.put('c', 3); // full: evicts 'b' (the MRU), keeps 'a'
c.get('a'); // 1

Audited: 2026-06-12 11:26 EDT

Implementation

V? get(K key) {
  if (!_values.containsKey(key)) return null;
  _touch(key);
  return _values[key];
}