aboutsummaryrefslogtreecommitdiff
path: root/internal/lru/cache.go
blob: 1aa96c52dba2444a47d90b39c29f5e19ecbdc3b7 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package lru

import "container/list"

// Cache is a non-concurrent weighted LRU cache.
//
// Methods on Cache are not safe for concurrent use.
type Cache[K comparable, V any] struct {
	maxWeight int64
	weightFn  WeightFunc[K, V]
	onEvict   OnEvictFunc[K, V]

	weight int64
	items  map[K]*list.Element
	lru    list.List
}