set method
void
set(
- K key,
- V value
Associates key with value; evicts oldest entry if at capacity.
Implementation
void set(K key, V value) {
if (_ttl != null) _expiresAt[key] = DateTime.now().add(_ttl);
if (_map.containsKey(key)) {
_order.remove(key);
} else if (_order.length >= _maxSize) {
final K evict = _order.removeAt(0);
_map.remove(evict);
_expiresAt.remove(evict);
}
_map[key] = value;
_order.add(key);
}