aboutsummaryrefslogtreecommitdiff
path: root/object/store/packed/internal/ingest/basecache.go
blob: 77419aa727963bdc2ead31dfeaf44009ed0391c6 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package ingest

import (
	"lindenii.org/go/furgit/internal/cache/clock"
	"lindenii.org/go/furgit/object/typ"
)

const baseCacheMaxWeight = 96 << 20

type baseCacheKey struct {
	offset int
}

type cachedContent struct {
	objectType typ.Type
	content    []byte
}

func newBaseCache(workers int) *clock.Clock[baseCacheKey, cachedContent] {
	return clock.New(baseCacheMaxWeight*uint64(workers), baseContentWeight) //#nosec G115
}

func baseContentWeight(_ baseCacheKey, base cachedContent) uint64 {
	return uint64(len(base.content)) + 32
}