putIfAbsentCheckedAsync method

FutureOr<V> putIfAbsentCheckedAsync(
  1. K key,
  2. FutureOr<V> ifAbsent(), {
  3. DateTime? now,
  4. Duration? keyTimeout,
})

Same as putIfAbsentChecked, but accepts an async function for ifAbsent.

Implementation

FutureOr<V> putIfAbsentCheckedAsync(K key, FutureOr<V> Function() ifAbsent,
    {DateTime? now, Duration? keyTimeout}) {
  if (checkEntry(key, now: now, keyTimeout: keyTimeout)) {
    return ifAbsent().resolveMapped((val) {
      put(key, val, now: now);
      return val;
    });
  } else {
    var t = _entriesPutTime[key];
    if (t == null) {
      return ifAbsent().resolveMapped((val) {
        put(key, val, now: now);
        return val;
      });
    } else {
      return _entries[key]!;
    }
  }
}