aboutsummaryrefslogtreecommitdiff
path: root/object/store/packed/basecache.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-12 12:43:30 +0000
committerGravatar Runxi Yu2026-06-12 12:43:30 +0000
commited1d706ee1cf3e3ac34bce8b295525bebff8bcb9 (patch)
tree721ac907565df0ad91d766d4c6b16b2eb029a55a /object/store/packed/basecache.go
parentobject/store/loose: Use SeedHistory (diff)
object/store/packed: Basic reading functionality
Diffstat (limited to 'object/store/packed/basecache.go')
-rw-r--r--object/store/packed/basecache.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/object/store/packed/basecache.go b/object/store/packed/basecache.go
new file mode 100644
index 00000000..7de4ec7b
--- /dev/null
+++ b/object/store/packed/basecache.go
@@ -0,0 +1,38 @@
+package packed
+
+import (
+ "lindenii.org/go/furgit/internal/cache/clock"
+ "lindenii.org/go/furgit/internal/format/packfile"
+)
+
+// baseCacheMaxWeight bounds the delta base cache weight.
+const baseCacheMaxWeight = 96 << 20
+
+// baseKey addresses an entry in one pack
+// as a delta base cache key.
+type baseKey struct {
+ pack *pack
+ offset uint64
+}
+
+// cachedBase is a cached delta base, i.e.,
+// its resolved object entry type and full content.
+//
+// content is shared with concurrent users;
+// it may only be returned to callers as a copy.
+//
+// Labels: Mut-No.
+type cachedBase struct {
+ entryType packfile.EntryType
+ content []byte
+}
+
+// newBaseCache creates the delta base cache.
+func newBaseCache() *clock.Clock[baseKey, cachedBase] {
+ return clock.New(baseCacheMaxWeight, baseWeight)
+}
+
+// baseWeight weighs one cached delta base.
+func baseWeight(_ baseKey, base cachedBase) uint64 {
+ return uint64(len(base.content)) + 32
+}