2024-01-15 15:23:42 +08:00
|
|
|
package lru
|
2024-01-08 15:39:39 +08:00
|
|
|
|
2024-01-15 11:42:18 +08:00
|
|
|
import "github.com/hashicorp/golang-lru/v2/simplelru"
|
2024-01-08 15:39:39 +08:00
|
|
|
|
2024-01-15 11:42:18 +08:00
|
|
|
type EvictCallback[K comparable, V any] simplelru.EvictCallback[K, V]
|
|
|
|
|
|
|
|
|
|
type LRU[K comparable, V any] interface {
|
2024-01-12 18:23:15 +08:00
|
|
|
Get(key K, fetch func() (V, error)) (V, error)
|
|
|
|
|
Del(key K) bool
|
|
|
|
|
Stop()
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-15 11:42:18 +08:00
|
|
|
type Target interface {
|
|
|
|
|
IncrGetHit()
|
|
|
|
|
IncrGetSuccess()
|
|
|
|
|
IncrGetFailed()
|
2024-01-12 18:23:15 +08:00
|
|
|
|
2024-01-15 11:42:18 +08:00
|
|
|
IncrDelHit()
|
|
|
|
|
IncrDelNotFound()
|
2024-01-12 18:23:15 +08:00
|
|
|
}
|