cache

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cache memoizes per-file lint findings keyed by a content + config hash, so re-linting unchanged files is near-instant. It is used only by plain `lint` (fix/diff/fmt always run fresh); the key folds in everything that can change a file's findings, so a stale result is never returned.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir() (string, error)

DefaultDir returns the per-user cache directory for doclint.

func Key

func Key(version, configHash, path string, content []byte) string

Key derives the cache key for a file from the invariants that affect its findings: the schema version, the doclint version, a hash of the resolved config, the file path, and the file content.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a content-addressed store of per-file findings.

func Open

func Open(dir string) *Cache

Open loads the cache from dir, returning an empty cache if it is absent or unreadable (a corrupt cache is never fatal — it just rebuilds).

func (*Cache) Clean

func (c *Cache) Clean() error

Clean removes the on-disk cache file.

func (*Cache) Entries

func (c *Cache) Entries() int

Entries reports how many file results are stored.

func (*Cache) Get

func (c *Cache) Get(key string) ([]rule.Finding, bool)

Get returns the cached findings for key, if present.

func (*Cache) Hits

func (c *Cache) Hits() int

Hits reports how many lookups were served from the cache this run.

func (*Cache) Put

func (c *Cache) Put(key string, findings []rule.Finding)

Put stores findings for key.

func (*Cache) Save

func (c *Cache) Save() error

Save persists the cache to disk when it changed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL