blob: 9659dd4ffa636be4e95848aee1821a552f5e272b (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package lru
// OnEvictFunc runs when an entry leaves the cache.
//
// It is called for evictions, explicit removals, Clear, and replacement by Add.
type OnEvictFunc[K comparable, V any] func(key K, value V)
func (cache *Cache[K, V]) evictOverBudget() {
for cache.weight > cache.maxWeight {
elem := cache.lru.Front()
if elem == nil {
return
}
cache.removeElem(elem)
}
}
|