onCapacity method
removes the entry denoted by key
. This is called if the capacity is reached.
Implementation
@override
CacheEntry<K, V>? onCapacity(K key) {
CacheEntry<K, V>? oldEntry = _internalMap.remove(key);
if (oldEntry != null && oldEntry.value != null) {
if (_weakMap.target == null)
_weakMap = WeakReference(LinkedHashMap<K, CacheEntry<K, V>>());
_weakMap.target![key] = oldEntry;
}
return oldEntry;
}