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.length >= _maxSize) {
final K evict = _order.removeAt(0);
_map.remove(evict);
_expiresAt.remove(evict);
}
if (!_order.contains(key)) _order.add(key);
_map[key] = value;
}