Documentation
¶
Overview ¶
Package cache provides an opt-in on-disk cache for compiler outputs keyed by source content + compiler version. Phase A caches the diagnostics slice returned by `kukicha check` so unchanged trees re-check near-instantaneously.
Enablement is opt-in via the KUKICHA_CACHE environment variable (set to "1"). Location defaults to $XDG_CACHE_HOME/kukicha/v1/ and can be overridden via KUKICHA_CACHE_DIR.
Index ¶
- Constants
- type Cache
- func (c *Cache) Debug() bool
- func (c *Cache) Enabled() bool
- func (c *Cache) Get(key string, out any) bool
- func (c *Cache) Key(sources map[string][]byte, tag string) string
- func (c *Cache) PerFileKey(filename string, source []byte, envHash, tag string) string
- func (c *Cache) Put(key string, val any) error
Constants ¶
const FormatVersion = 1
FormatVersion bumps whenever the on-disk cache payload shape changes. Bumping it invalidates every existing cache entry on the next lookup.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a content-addressed disk cache. A zero or disabled Cache is safe to use; Get always misses and Put is a no-op.
func Open ¶
Open returns a Cache rooted at the user's cache dir (honoring KUKICHA_CACHE_DIR if set). If KUKICHA_CACHE is not "1" the returned Cache reports Enabled()==false and is a no-op for Get/Put.
func (*Cache) Get ¶
Get tries to load a cached value for key into out (which must be a JSON-unmarshallable pointer). Returns true on hit, false on miss. Stale/corrupt entries are treated as misses; callers should not infer correctness from the return value beyond "use out" vs "recompute".
func (*Cache) Key ¶
Key computes a deterministic cache key from sources + tag. sources maps file path to source bytes; paths are sorted before hashing so iteration order doesn't affect the result. The tag distinguishes callers with the same sources but different desired outputs (e.g. "check" vs "build").
func (*Cache) PerFileKey ¶ added in v0.7.0
PerFileKey computes a deterministic cache key for a single-file analysis result, keyed on the file's source bytes plus a hash of the external symbols visible to it (typically semantic.ExportsListHash of the file's dependency siblings). Like Key it incorporates the compiler version and format version so cache upgrades transparently invalidate.