saveForever<T> method

Future<T> saveForever<T>(
  1. String key,
  2. Future<T> callback()
)

Saves a value in the cache without an expiration time.

Implementation

Future<T> saveForever<T>(String key, Future<T> Function() callback) async {
  if (_store.containsKey(key)) {
    return _store[key]!.value as T;
  }

  final T value = await callback();
  _store[key] = _CacheEntry(value: value);
  return value;
}