checkPurgeEntriesLimit method

void checkPurgeEntriesLimit()

Removed purged entries over maxPurgedEntries limit.

Implementation

void checkPurgeEntriesLimit() {
  if (_purged != null && maxPurgedEntries != null && maxPurgedEntries! > 0) {
    var purged = _purged!;
    var needToRemove = purged.length - maxPurgedEntries!;
    if (needToRemove > 0) {
      var del = <K>[];
      for (var k in purged.keys) {
        del.add(k);
        if (del.length >= needToRemove) break;
      }

      if (del.isNotEmpty) {
        for (var k in del) {
          purged.remove(k);
        }
        _expireCache();
      }
    }
  }
}