cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashContent

func HashContent(content []byte) string

HashContent computes a SHA-256 hex digest of the given content bytes.

Types

type Cache

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

Cache manages content hashes and template usage tracking for incremental build detection. Passed in-memory between builds.

func New

func New() *Cache

New creates an empty cache with no entries.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all stored hashes and template tracking data.

func (*Cache) Clone

func (c *Cache) Clone() *Cache

Clone returns a deep copy of the cache. Used by BuildIncremental to carry forward hashes for unchanged pages without re-hashing them.

func (*Cache) Entries

func (c *Cache) Entries() int

Entries returns the number of stored content hashes.

func (*Cache) GetHash

func (c *Cache) GetHash(path string) string

GetHash retrieves the stored content hash for a source file path. Returns empty string if no hash is stored.

func (*Cache) HasChanged

func (c *Cache) HasChanged(path, currentHash string) bool

HasChanged returns true if the given hash differs from the stored hash for the path (or if no hash is stored). Used during rebuild to decide whether a file needs re-processing.

func (*Cache) InvalidatedByDirectoryData

func (c *Cache) InvalidatedByDirectoryData(dirPath string) []string

InvalidatedByDirectoryData returns page paths that need rebuilding when a directory's _data.yaml changes. Only pages in that directory are affected.

func (*Cache) InvalidatedByGlobalData

func (c *Cache) InvalidatedByGlobalData() []string

InvalidatedByGlobalData returns all page paths that need rebuilding when global data (data/ directory files) changes.

func (*Cache) InvalidatedPages

func (c *Cache) InvalidatedPages(changedTemplate string) []string

InvalidatedPages returns the list of page paths that need rebuilding because the given template changed. Returns nil if the template is not tracked.

func (*Cache) IsConfigChanged

func (c *Cache) IsConfigChanged(configHash string) bool

IsConfigChanged returns true if the config hash differs from the stored hash. A config change triggers a full rebuild of all pages.

func (*Cache) SetHash

func (c *Cache) SetHash(path, hash string)

SetHash records the content hash for a source file path.

func (*Cache) ShouldSkipFile

func (c *Cache) ShouldSkipFile(path string, currentContent []byte) bool

ShouldSkipFile returns true if the file content hash matches the stored hash, meaning the file has not changed and can be skipped entirely (no re-parse, no re-render).

func (*Cache) TrackDirectoryData

func (c *Cache) TrackDirectoryData(pagePath, dirPath string)

TrackDirectoryData records that pages in a directory depend on that directory's _data.yaml.

func (*Cache) TrackTemplateUsage

func (c *Cache) TrackTemplateUsage(pagePath, templatePath string)

TrackTemplateUsage records that a page uses a specific template. Called during layout resolution to build the invalidation map.

Jump to

Keyboard shortcuts

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