remove method Null safety

  1. @override
Future<void> remove(
  1. String key
)

Removes the mapping for a key from this stash if it is present.

  • key: key whose mapping is to be removed from the stash

Implementation

@override
Future<void> remove(String key) {
  // #region Statistics
  Stopwatch? watch;
  Future<void> Function(dynamic) posRemove = (_) => Future<void>.value();
  if (statsEnabled) {
    watch = clock.stopwatch()..start();
    posRemove = (_) {
      stats.increaseRemovals();
      if (watch != null) {
        stats.addRemoveTime(watch.elapsedMicroseconds);
        watch.stop();
      }

      return Future<void>.value();
    };
  }
  // #endregion
  return _primary
      .remove(key)
      .then((_) => _secondary.remove(key))
      .then(posRemove);
}