cache

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(absPath string) string

Key returns a cache key derived from the absolute path (first 16 hex chars of SHA256).

func ReadFile

func ReadFile(path string) (*format.Output, error)

ReadFile reads a raw JSON output file (not a cache wrapper).

Types

type Config

type Config struct {
	// Cache is where the cache files should go.
	Cache string `env:"INFRACOST_CLI_CACHE_DIRECTORY"`

	// TTL is how long cached results remain valid.
	TTL time.Duration `env:"INFRACOST_CLI_CACHE_TTL" default:"1h"`
	// contains filtered or unexported fields
}

func (*Config) ForPath added in v0.0.7

func (c *Config) ForPath(absPath string) (*format.Output, error)

ForPath returns cached results for the given absolute path.

The entry must be within TTL and the source files must not have been modified since the entry was created.

func (*Config) Latest added in v0.0.7

func (c *Config) Latest(allowStale bool) (*format.Output, error)

Latest returns the most recent cached result within TTL.

When allowStale is false, the entry is also rejected if any source file has been modified since the entry was created. Set allowStale to true when reading for comparison (e.g. diffing against a prior run).

func (*Config) LoadManifest added in v0.0.7

func (c *Config) LoadManifest() (*Manifest, error)

func (*Config) Process added in v0.0.3

func (c *Config) Process()

func (*Config) SaveManifest added in v0.0.7

func (c *Config) SaveManifest(m *Manifest) error

func (*Config) Write

func (c *Config) Write(absPath string, data *format.Output) error

Write writes the output data to the cache for the given absolute path and updates the manifest accordingly.

type Manifest added in v0.0.7

type Manifest struct {
	// Entries is keyed by the cache key (hash of the absolute source path).
	Entries map[string]ManifestEntry `json:"entries"`
}

Manifest holds the index of all cache entries.

type ManifestEntry added in v0.0.7

type ManifestEntry struct {
	// Version is the schema version of the cache entry.
	Version int
	// CreatedAt is when this entry was written.
	CreatedAt time.Time
	// SourcePath is the absolute path of the directory that was scanned.
	SourcePath string
}

ManifestEntry holds metadata for a single cached result.

Jump to

Keyboard shortcuts

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