flexible<T> method
Stale while revalidate. For fresh the value is served as it is.
After that, until fresh + stale, the old value is still served
at once, and one caller runs compute in the background.
await Cache().flexible('stats', Duration(minutes: 1),
Duration(minutes: 5), () => loadStats());
Implementation
Future<T> flexible<T>(
String key,
Duration fresh,
Duration stale,
FutureOr<T> Function() compute, {
T Function(Object? json)? decode,
}) {
return repository.flexible<T>(key, fresh, stale, compute, decode: decode);
}