From fec8b64975f952e2fa5fa8478b09dced87f0fa7b Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 6 Mar 2026 04:43:03 +0800 Subject: internal/lru: Split --- internal/lru/cache.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 internal/lru/cache.go (limited to 'internal/lru/cache.go') diff --git a/internal/lru/cache.go b/internal/lru/cache.go new file mode 100644 index 00000000..1aa96c52 --- /dev/null +++ b/internal/lru/cache.go @@ -0,0 +1,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 +} -- cgit v1.3.1-10-gc9f91