NewLFU init the LFU cache with capacity
(capacity int)
| 31 | |
| 32 | // NewLFU init the LFU cache with capacity |
| 33 | func NewLFU(capacity int) LFU { |
| 34 | return LFU{ |
| 35 | len: 0, |
| 36 | cap: capacity, |
| 37 | minFreq: math.MaxInt, |
| 38 | itemMap: make(map[string]*list.Element), |
| 39 | freqMap: make(map[int]*list.List), |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // initItem to init item for LFU |
| 44 | func initItem(k string, v any, f int) item { |