cache

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(cachedHashes, diskHashes map[string]string) (changed, deleted []string)

Diff computes which files changed or were deleted. diskHashes: file_path → hash for all files currently on disk Returns (changed, deleted) file paths.

Types

type Cache

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

Cache manages the SQLite build cache.

func Open

func Open(path string) (*Cache, error)

Open opens or creates the cache database at the given path.

func (*Cache) ClearContentHTML added in v0.2.0

func (c *Cache) ClearContentHTML() error

ClearContentHTML is a no-op — content_html is no longer stored in the cache. Pages that need re-rendering are detected via file hash changes and the layoutChanged / renderVersion flags in build state.

func (*Cache) Close

func (c *Cache) Close() error

Close closes the database.

func (*Cache) Delete

func (c *Cache) Delete(filePath string) error

Delete removes a page record from the cache.

func (*Cache) DeleteMany

func (c *Cache) DeleteMany(filePaths []string) error

DeleteMany removes multiple page records.

func (*Cache) GetState

func (c *Cache) GetState(key string) (string, error)

GetState retrieves a build state value by key.

func (*Cache) LoadAll

func (c *Cache) LoadAll() ([]*PageRecord, error)

LoadAll returns all cached page records without content_plain. Call LoadPlainTexts separately when the search index needs to be rebuilt.

func (*Cache) LoadHashes

func (c *Cache) LoadHashes() (map[string]string, error)

LoadHashes returns a map of file_path → file_hash for all cached pages.

func (*Cache) LoadPlainTexts added in v0.2.0

func (c *Cache) LoadPlainTexts() (map[string]string, error)

LoadPlainTexts returns file_path → content_plain for all cached pages. Called only when the search index needs rebuilding (contentChange = true).

func (*Cache) LoadStatMap added in v0.2.0

func (c *Cache) LoadStatMap() (map[string]StatEntry, error)

LoadStatMap returns a map of file_path → StatEntry (hash + size + mtime). Used as a pre-filter to skip SHA-256 when stat fields match the cached values.

func (*Cache) Save

func (c *Cache) Save(r *PageRecord) error

Save upserts a single page record into the cache.

func (*Cache) SaveBatch added in v0.2.0

func (c *Cache) SaveBatch(records []*PageRecord) error

SaveBatch upserts all records in a single transaction — far faster than calling Save() per page on large corpora.

func (*Cache) SetState

func (c *Cache) SetState(key, value string) error

SetState stores a build state value.

type PageRecord

type PageRecord struct {
	FilePath      string
	FileHash      string
	FileSize      int64
	FileMtime     int64
	Permalink     string
	Title         string
	LinkTitle     string
	Description   string
	Tags          []string
	Categories    []string
	Keywords      []string
	Date          time.Time
	PublishDate   time.Time
	ExpiryDate    time.Time
	Lastmod       time.Time
	Section       string
	Lang          string
	Depth         int
	WordCount     int
	ReadingTime   int
	Summary       string
	ContentPlain  string
	ContentHTML   string
	Params        map[string]any
	Weight        int
	NoIndex       bool
	ExcludeSearch bool
	Type          string
	Layout        string
	Slug          string
	URL           string
	Aliases       []string
	Draft         bool
	Kind          string
	BuiltAt       int64
}

PageRecord is a row from page_cache.

type StatEntry added in v0.2.0

type StatEntry struct {
	Hash  string
	Size  int64
	Mtime int64
}

StatEntry holds the stat-based pre-filter data for a cached file.

Jump to

Keyboard shortcuts

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