Documentation
¶
Overview ¶
Package cache manages the local graph cache stored under ~/.supermodel/cache/. Graphs are keyed by the SHA-256 hash of the uploaded repository ZIP, matching the content-addressed scheme used by the Supermodel API.
This is a shared kernel package. It must contain no business logic. Slice packages under internal/ may import it freely.
Index ¶
- Constants
- func AnalysisKey(fingerprint, analysisType, version string) string
- func Evict(hash string) error
- func Get(hash string) (*api.Graph, error)
- func GetJSON(hash string, v any) (bool, error)
- func HashFile(path string) (string, error)
- func NewestEntry() time.Time
- func Prune(maxAge time.Duration) (int, error)
- func Put(hash string, g *api.Graph) error
- func PutJSON(hash string, v any) error
- func RepoFingerprint(dir string) (string, error)
- func Stats() (count int, sizeBytes int64)
Constants ¶
const DefaultTTL = 30 * 24 * time.Hour
DefaultTTL is how long cached entries are considered fresh.
Variables ¶
This section is empty.
Functions ¶
func AnalysisKey ¶ added in v0.4.0
AnalysisKey builds a cache key for a specific analysis type on a repo state. version is the CLI version string and is included so the cache is invalidated automatically after an upgrade.
func GetJSON ¶ added in v0.4.1
GetJSON reads the cached JSON for hash and unmarshals it into v. Returns (true, nil) on hit, (false, nil) on miss, (false, err) on error.
func NewestEntry ¶ added in v0.6.0
NewestEntry returns the modification time of the most recently written cache entry, or the zero time if the cache is empty.
func Prune ¶ added in v0.6.0
Prune removes cache entries older than maxAge. Returns the number removed.
func PutJSON ¶ added in v0.4.1
PutJSON serialises v as JSON and stores it under hash. Unlike Put, it works with any value type — useful for dead-code and blast-radius results.
func RepoFingerprint ¶ added in v0.4.0
RepoFingerprint returns a fast, content-based cache key for the repo at dir.
For clean git repos (~1ms): returns the commit SHA. For dirty git repos (~100ms): returns commitSHA:dirtyHash. For non-git dirs: returns empty string and an error.
Types ¶
This section is empty.