onWillRelease method

  1. @override
void onWillRelease(
  1. TIdentifier id
)
override

Custom logic to be executed before a Cache.release.

Implementation

@override
void onWillRelease(TIdentifier id) {
  // id has been released, add it to the front of the removal queue. If
  // necessary, the least recently used items will be removed in onDidRemove
  // which the cache will call after any pending async value factory
  // associated with id completes. Items are added to the removal queue in
  // onWillRelease rather than onDidRelease to allow a get called before an
  // async value factory completes to cancel an unnecessary removal.
  if (!_removalQueue.contains(id)) {
    _removalQueue.addFirst(id);
  }
}