checkPurgeEntriesLimit method

void checkPurgeEntriesLimit()

Removed purged entries over maxPurgedEntries limit.

Implementation

void checkPurgeEntriesLimit() {
  var purged = _purged;
  var maxPurgedEntries = this.maxPurgedEntries;

  if (purged != null && maxPurgedEntries != null && maxPurgedEntries > 0) {
    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();
      }
    }
  }
}