get method

Future<V?> get(
  1. K key
)

Returns the value associated with key.

If the key is inflight, it will get the Future of that inflight key. Will invalidate the entry if it is expired.

Implementation

Future<V?> get(K key) async {
  if (_cache.containsKey(key) && isCacheEntryExpired(key)) {
    _cache.remove(key);
    return null;
  }
  if (_inflightSet.containsKey(key) && isInflightEntryExpire(key)) {
    _inflightSet.remove(key);
    return null;
  }
  return _cache[key]?._cacheObject ?? _inflightSet[key]?._completer.future;
}