put<T> method

Future<T> put<T>(
  1. String name, {
  2. bool? cached,
  3. Iterable<Object?> keyProps = const [],
  4. required Future<T> callback(),
})

Implementation

Future<T> put<T>(
  String name, {
  bool? cached,
  Iterable<Object?> keyProps = const [],
  required Future<T> Function() callback,
}) async {
  cached ??= false;
  if (!cached) return callback();
  final k = hashKey(T, name, keyProps);
  final x = _db[k];
  if (x is T) return x;
  return _db[k] ??= await callback();
}