cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(parts ...string) string

Hash returns a hex SHA-256 of the given parts, used to build cache keys from multiple inputs (e.g. all repo HEADs, or HEAD plus plan-file hash) so cached entries invalidate when any contributing input changes.

Types

type Cache

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

Cache is a small file-backed store for generated responses, keyed by repository name, HEAD SHA, provider, and command name. Entries expire after a caller-supplied max age.

func New

func New(dir string) (*Cache, error)

New creates (or opens) a cache rooted at dir. The directory is created with restrictive permissions if it does not already exist, and any stale temp files left by interrupted writes are swept.

func (*Cache) Delete

func (c *Cache) Delete(repo, headSHA, provider, command string) error

Delete removes a cached entry, if present. Missing files are not an error.

func (*Cache) GetRaw

func (c *Cache) GetRaw(repo, headSHA, provider, command string, maxAge time.Duration) (json.RawMessage, bool)

GetRaw returns the cached raw JSON payload if one exists and is newer than maxAge. The boolean is false on miss, expired entry, or any read/decode error.

func (*Cache) PutRaw

func (c *Cache) PutRaw(repo, headSHA, provider, command string, payload json.RawMessage) error

PutRaw stores a raw JSON payload, writing atomically via a temp file + rename.

Jump to

Keyboard shortcuts

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