cache

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cache fingerprints a group's declared inputs and persists the result so unchanged groups can be skipped on subsequent runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compute

func Compute(spec *config.Cache, command string, params []string) (string, error)

Compute returns a content fingerprint for the given cache spec. The fingerprint changes when the method, command, params, or any matched input file changes. A glob that matches nothing contributes nothing, so adding the first matching file naturally changes the fingerprint.

func WritesPresent

func WritesPresent(spec *config.Cache) bool

WritesPresent reports whether every declared output glob matches at least one existing path. A missing output invalidates a would-be cache hit.

Types

type Entry

type Entry struct {
	Fingerprint string           `json:"fingerprint"`
	Result      result.RunResult `json:"result"`
	Command     string           `json:"command"`
	Params      []string         `json:"params"`
	UpdatedAt   time.Time        `json:"updatedAt"`
}

Entry is a persisted cache record for one group.

type FileStore

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

FileStore persists one JSON entry per group under a directory.

func NewFileStore

func NewFileStore(dir string) *FileStore

NewFileStore returns a store rooted at dir. The directory is created lazily on the first Save.

func (*FileStore) Load

func (s *FileStore) Load(group string) (*Entry, bool)

Load returns the stored entry for a group, or (nil, false) if absent or unreadable.

func (*FileStore) Save

func (s *FileStore) Save(group string, e *Entry) error

Save writes the entry for a group, creating the cache directory if needed.

type Store

type Store interface {
	Load(group string) (*Entry, bool)
	Save(group string, e *Entry) error
}

Store loads and saves cache entries keyed by group name.

Jump to

Keyboard shortcuts

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