disposeInstances method

int disposeInstances(
  1. int? amountToRemove
)

Implementation

int disposeInstances(int? amountToRemove) {
  if (amountToRemove == null || amountToRemove < 1) return 0;

  var keys = List.from(_cacheInstances.keys);

  var removed = 0;
  for (var k in keys) {
    _cacheInstances.remove(k);
    removed++;

    if (removed >= amountToRemove) {
      return removed;
    }
  }

  return removed;
}