Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore is a file-backed implementation of Store.
Layout under root:
{root}/{kind}/{fileHash[:2]}/{fileHash[2:]}-{ruleSetHash}.bin
Two-level sharding on the file-content hash keeps no single directory larger than 256 children even in large repos. The ruleSetHash suffix allows the same source file to have independent entries for different rule configurations.
func New ¶
New returns a FileStore rooted at dir. The directory is created on the first Put call; New itself does no I/O.
func (*FileStore) Get ¶
Get retrieves a cached value. Returns (nil, false) on any miss or I/O error.
func (*FileStore) Invalidate ¶
Invalidate removes entries from the store. With no arguments it clears everything. With ruleIDs it removes every entry whose filename contains any of the given IDs as a substring of the ruleSetHash hex.
Note: in Phase 0 the ruleSetHash is an opaque hash; per-rule targeting requires rule metadata to embed rule checksums so each rule ID maps to a deterministic ruleSetHash prefix. Until that lands, passing any ruleIDs clears the whole store (conservative but always correct).
type Key ¶
Key uniquely identifies one entry in the store.
FileHash is the full SHA-256 of the source file's bytes. RuleSetHash encodes the active rule IDs and their configuration (16 bytes). Kind scopes the entry to its owning subsystem so KindIncremental and KindOracle entries for the same file never collide.
type Stats ¶
type Stats struct {
EntryCount int
TotalBytes int64
HitRate float64 // populated by callers that track hits/misses
ByKind map[Kind]KindStats // per-kind breakdown
}
Stats summarises utilisation for krit cache stats.
type Store ¶
type Store interface {
// Get retrieves a cached value by key. Returns (nil, false) on miss.
Get(key Key) ([]byte, bool)
// Put stores a value, overwriting any existing entry for the key.
Put(key Key, value []byte) error
// Invalidate removes all entries whose on-disk path encodes one of
// the given rule IDs in their RuleSetHash prefix directory. This is
// a best-effort scan; it never returns an error for individual
// missing entries.
Invalidate(ruleIDs ...string) error
// Stats returns a point-in-time summary of cache utilisation.
Stats() (Stats, error)
}
Store is a content-hash-keyed byte store. Each subsystem encodes its own payload into []byte; the store owns only persistence and invalidation.