Documentation
¶
Overview ¶
Package cache persists and restores the documentation index to avoid full rebuilds.
Index ¶
- Constants
- func CachePath() string
- func ComputeFingerprint(entries []FileEntry) string
- func InvalidateCache() error
- func ParseFileEntryKey(key string) (source, relPath string)
- func SaveCache(idx *index.DocIndex, fingerprint string, ...) error
- func SaveCacheTo(path string, idx *index.DocIndex, fingerprint string, ...) error
- type CacheEnvelope
- type FileDiff
- type FileEntry
- type SourceInfo
Constants ¶
const CacheVersion = 4
CacheVersion is incremented when the cache format changes, invalidating old caches.
Variables ¶
This section is empty.
Functions ¶
func CachePath ¶
func CachePath() string
CachePath returns the default file path for the index cache.
func ComputeFingerprint ¶
ComputeFingerprint returns a SHA-256 hash of sorted file entries for cache invalidation.
func InvalidateCache ¶
func InvalidateCache() error
InvalidateCache deletes the cache file at the default path.
func ParseFileEntryKey ¶
ParseFileEntryKey splits a cache key "source:rel/path.md" into source name and relative path.
func SaveCache ¶
func SaveCache(idx *index.DocIndex, fingerprint string, fileResults map[string]*index.FileResult, files map[string]int64) error
SaveCache writes the index to the default cache path.
func SaveCacheTo ¶
func SaveCacheTo(path string, idx *index.DocIndex, fingerprint string, fileResults map[string]*index.FileResult, files map[string]int64) error
SaveCacheTo writes the index to the given path. InvertedIndex and DocumentFrequency are omitted since they are cheaply rebuilt from chunk term frequencies on load.
Types ¶
type CacheEnvelope ¶
type CacheEnvelope struct {
Version int
Fingerprint string
CreatedAt string
Index *index.DocIndex
FileResults map[string]*index.FileResult
Files map[string]int64
}
CacheEnvelope wraps a cached index with per-file metadata for incremental rebuilds.
func LoadCache ¶
func LoadCache() (*CacheEnvelope, error)
LoadCache reads the index from the default cache path.
func LoadCacheFrom ¶
func LoadCacheFrom(path string) (*CacheEnvelope, error)
LoadCacheFrom reads the index from the given path. It rebuilds InvertedIndex and DocumentFrequency which are omitted from the cache.
type FileDiff ¶
type FileDiff struct {
Added []FileEntry // files on disk but not in cache
Modified []FileEntry // files whose mtime changed since cache was written
Removed []string // keys in cache but no longer on disk
}
FileDiff describes the changes between a cached file set and the current filesystem.
func DiffEntries ¶
DiffEntries compares the cached per-file mtimes against the current file entries and returns the set of added, modified, and removed files.
func (FileDiff) ChangedCount ¶
ChangedCount returns the total number of files that differ.
type FileEntry ¶
FileEntry records a file's path and modification time for fingerprinting.
func CollectFileEntries ¶
func CollectFileEntries(sources []SourceInfo) ([]FileEntry, error)
CollectFileEntries walks all sources and returns their file entries for fingerprinting. It applies the same directory skip rules and ignore patterns as the indexer so the fingerprint only covers files that will actually be indexed.
type SourceInfo ¶
SourceInfo provides the name, path, and ignore patterns needed to collect file entries.