get method
V?
get(
- K key
Returns the value for key, or null; promotes key to most recently used.
Returns null if the entry has expired (when the cache was created with a TTL).
Implementation
V? get(K key) {
if (_ttl != null) {
final DateTime? exp = _expiresAt[key];
if (exp != null && DateTime.now().isAfter(exp)) {
final _ = exp;
_order.remove(key);
_map.remove(key);
_expiresAt.remove(key);
return null;
}
}
final V? v = _map[key];
if (v == null) return null;
_order.remove(key);
_order.add(key);
return v;
}