cache

package
v0.0.0-...-f9a56e6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cache manages CLI cache files in the XDG cache directory.

The cache stores metadata about the registry index (version and fetch timestamp) so that commands can reuse a known-good canonical version without a network call. The actual index data is cached by CUE's module cache; this package only tracks which version was last fetched and when.

Index

Constants

View Source
const (

	// DefaultMaxAge is the default staleness threshold for the index cache.
	DefaultMaxAge = 24 * time.Hour
)

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the cache directory path, respecting XDG_CACHE_HOME.

func WriteIndex

func WriteIndex(version string) error

WriteIndex writes the index version and current timestamp to the cache file. Creates the cache directory if needed. Errors are returned but callers should treat them as non-fatal (best-effort).

Types

type IndexCache

type IndexCache struct {
	Updated time.Time
	Version string
}

IndexCache holds the cached registry index metadata.

func ReadIndex

func ReadIndex() (IndexCache, error)

ReadIndex reads the index cache from disk. Returns an error if the file is missing or malformed.

func (IndexCache) IsFresh

func (c IndexCache) IsFresh(maxAge time.Duration) bool

IsFresh returns true if the cache was updated within maxAge.

Jump to

Keyboard shortcuts

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