cache

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cache provides build caching for Ludus pipeline stages. Each stage computes a hash key from its inputs (git state, config values, file metadata). If the key matches a cached entry, the stage is skipped. Cache entries are stored in .ludus/cache.json.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSkip

func CheckSkip(stage StageKey, hash, projectName string, noCache bool) bool

CheckSkip loads the cache and returns true (with a skip message printed) if the stage is up to date. When noCache is true the check is bypassed. Returns false when the build should proceed.

func ContainerKey

func ContainerKey(cfg *config.Config, serverBuildDir string) string

ContainerKey computes the cache key for the container build stage. It hashes a manifest of filenames and sizes in the server build directory.

func EngineKey

func EngineKey(cfg *config.Config) string

EngineKey computes the cache key for the engine build stage.

func GameClientKey

func GameClientKey(cfg *config.Config, engineHash string, platform string) string

GameClientKey computes the cache key for the game client build stage.

func GameServerKey

func GameServerKey(cfg *config.Config, engineHash string) string

GameServerKey computes the cache key for the game server build stage.

func RecordBuild

func RecordBuild(stage StageKey, hash string, dryRun bool)

RecordBuild updates the cache entry for a stage on success. A dry-run is side-effect free: it returns without recording an entry, so a subsequent real build is not skipped as "up to date (cached)".

func Save

func Save(c *Cache) error

Save writes cache to .ludus/cache.json.

Types

type Cache

type Cache struct {
	Entries map[StageKey]*Entry `json:"entries"`
}

Cache holds all stage cache entries.

func Load

func Load() (*Cache, error)

Load reads .ludus/cache.json, returning an empty Cache if the file is missing.

func (*Cache) IsHit

func (c *Cache) IsHit(stage StageKey, hash string) bool

IsHit returns true if the stage has a cached entry matching the given hash.

func (*Cache) MissReason

func (c *Cache) MissReason(stage StageKey, hash string) string

MissReason explains why a cache check missed for a stage. Returns empty string if the cache is a hit (i.e., the stage is up to date).

func (*Cache) Set

func (c *Cache) Set(stage StageKey, hash string, builtAt string)

Set updates the cache entry for a stage.

type Entry

type Entry struct {
	Hash    string `json:"hash"`
	BuiltAt string `json:"builtAt"`
}

Entry is a single cache entry recording the input hash for a stage.

type StageKey

type StageKey string

StageKey identifies a pipeline stage for caching.

const (
	StageEngine         StageKey = "engine"
	StageGameServer     StageKey = "game_server"
	StageGameClient     StageKey = "game_client"
	StageContainerBuild StageKey = "container_build"
)

Jump to

Keyboard shortcuts

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