aboutsummaryrefslogtreecommitdiff
path: root/internal/lru/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/lru/cache.go')
-rw-r--r--internal/lru/cache.go16
1 files changed, 16 insertions, 0 deletions
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
+}