limitEntries static method
Implementation
static int limitEntries(Map cache, int maxCacheEntries) {
if (cache.isEmpty) return 0;
// Cache limit is never unlimited
if (maxCacheEntries < 0) maxCacheEntries = 0;
var removed = 0;
while (cache.length > maxCacheEntries) {
var key = cache.keys.first;
print(
'-- removing from cache: $key > ${cache.length} / $maxCacheEntries');
cache.remove(key);
removed++;
}
return removed;
}