purge method
clear expired cache holders
Implementation
int purge({double? now}) {
now ??= Time.currentTimestamp;
int count = 0;
// copy the keys since the map is modified below
Iterable allKeys = List.of(keys);
CacheHolder? holder;
for (K key in allKeys) {
holder = _holderMap[key];
if (holder == null || holder.isDeprecated(now: now)) {
// remove expired holders
_holderMap.remove(key);
++count;
}
}
return count;
}