cache

package
v0.2026249.1030 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 4 Imported by: 6

Documentation

Overview

Package cache provides the ONE shared persistent-cache mechanism for the status hot path (R3 — the image list, the image labels, and the submodule verdicts all use the same read-file → unmarshal → TTL-check → miss path and the same atomic write). The caches live under the charly dir (~/.config/charly/cache/), keyed by a content key, with a TTL policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Invalidate

func Invalidate(path string)

Invalidate removes the cache file (the build/deploy commands call this when a new image is created, so the next status run re-fetches the fresh list).

func Read

func Read(path, key string, ttl time.Duration, out any) bool

Read returns the cached value for key if fresh (within ttl), decoding it into out. Returns false on a miss (absent, corrupt, stale, or a decode error).

func Write

func Write(path, key string, value any)

Write persists value under key in the cache file, atomically (tempfile + rename). Best-effort: a write failure is silent (the cache is an optimization, never a correctness dependency).

Types

type Entry

type Entry struct {
	Value    json.RawMessage `json:"value"`
	Resolved time.Time       `json:"resolved"`
}

Entry is one cached value + when it was resolved (RFC3339).

type File

type File struct {
	Entries map[string]Entry `json:"entries"`
}

File is the on-disk cache shape: key -> entry (value + resolution time).

Jump to

Keyboard shortcuts

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