getOrUpdate method

Future<V?> getOrUpdate(
  1. K key,
  2. CacheBuilderFn<V> builder
)

Retrieve cache value associated with key.

In case the value is expired, cache new value from builder and return it.

Implementation

Future<V?> getOrUpdate(K key, CacheBuilderFn<V> builder) async {
  return get(key) ?? add(key, await builder());
}