get method

  1. @override
Future<V?> get(
  1. K k, {
  2. V? fallback,
})
override

Get value in cache or get fallback or null

Implementation

@override
Future<V?> get(K k, {V? fallback}) async {
  if(exist(k)){
    return _cache[k];
  }

  if(_futures.containsKey(k)){
    final res = await _futures[k]?.call();
    _cache[k] = res as V;

    return res;
  }

  if(fallback != null){
    return fallback;
  }

  return null;
}