cache

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 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) ClearDependencies added in v0.6.0

func (c *Cache) ClearDependencies()

ClearDependencies resets all content page dependency tracking without affecting content hashes, template tracking, or virtual page tracking. Called before re-tracking dependencies on each build so stale entries from previous builds do not persist (issue #1100).

func (*Cache) ClearVirtualPages added in v0.5.0

func (c *Cache) ClearVirtualPages()

ClearVirtualPages removes all virtual page tracking and dependency tracking without affecting content hashes or template tracking. Called before re-populating virtual pages after each build so stale entries don't persist.

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) InvalidatedVirtualPages added in v0.5.0

func (c *Cache) InvalidatedVirtualPages(changedFile string) []string

InvalidatedVirtualPages returns the virtual page RelPaths that depend on the given source file. Returns nil if no virtual page tracks the given source file as a dependency (issue #1058).

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) PagesForDependency added in v0.6.0

func (c *Cache) PagesForDependency(depPath string) []string

PagesForDependency returns the content page RelPaths that depend on the given external file. Returns nil if no page tracks the given file as a dependency (issue #1100).

func (*Cache) SetHash

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

SetHash records the content hash for a source file path. Empty keys are silently discarded — taxonomy pages have empty RelPath and the Build() hash loop would create a spurious entry.

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) TrackDependency added in v0.6.0

func (c *Cache) TrackDependency(pageRelPath, depPath string)

TrackDependency records that a content page depends on an external file. Builds a reverse map so PagesForDependency can return all pages affected by a source file change (issue #1100).

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.

func (*Cache) TrackVirtualDependency added in v0.5.0

func (c *Cache) TrackVirtualDependency(virtualRelPath, sourcePath string)

TrackVirtualDependency records that a virtual page depends on a source file outside the content directory. Builds a reverse map so InvalidatedVirtualPages can return all virtual pages affected by a source file change (issue #1058).

func (*Cache) TrackVirtualPage added in v0.5.0

func (c *Cache) TrackVirtualPage(relPath string)

TrackVirtualPage records a RelPath as a virtual page injected by onPagesReady. Used by BuildIncremental to pre-populate renderRelPaths on the next rebuild so virtual pages aren't filtered out (issue #970).

func (*Cache) UntrackPageDependencies added in v0.6.0

func (c *Cache) UntrackPageDependencies(pageRelPath string)

UntrackPageDependencies removes a single page from every dependency set. Used by BuildIncremental to clear stale deps for pages being re-rendered without wiping deps for skipped pages (issue #1100).

func (*Cache) VirtualPagePaths added in v0.5.0

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

VirtualPagePaths returns all RelPaths tracked as virtual pages. Returns an empty (non-nil) slice when no virtual pages are tracked.

Jump to

Keyboard shortcuts

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