Documentation
¶
Overview ¶
Package cache provides opt-in memoization for materialize.Materialize.
The kernel deliberately holds no materialize cache (Principle I — the kernel stays stateless, and invalidation policy differs per consumer: the operator keys on a CR generation, the CLI opts out and relies on CUE's on-disk module cache). Consumers that want memoization construct a MaterializeCache themselves, derive a key with Key, and wrap their Materialize calls.
Unlike schema.Cache (a single-value sync.Once memo of the core schema), this is a multi-entry keyed cache — a different shape, hence a separate type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Key ¶
Key derives a stable cache key from a platform's #registry subtree — the input that fully determines materialization (Q2: registry-only). The key is invariant to field ordering and to enable defaulting (an explicit `enable: true` hashes the same as the default), so two semantically-identical registries map to the same key.
The whole-spec alternative (hashing metadata too) was rejected: metadata does not affect the materialized transformer index, so keying on it would cause spurious cache misses on cosmetic edits.
Types ¶
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU is the reference MaterializeCache: a fixed-capacity, least-recently- used cache safe for concurrent use. A non-positive capacity disables caching (Put is a no-op, Get always misses).
func NewLRU ¶
NewLRU returns an LRU holding at most capacity entries. A non-positive capacity yields a cache that never stores anything.
func (*LRU) Get ¶
func (c *LRU) Get(key string) (*materialize.MaterializedPlatform, bool)
Get implements MaterializeCache.
func (*LRU) Put ¶
func (c *LRU) Put(key string, mp *materialize.MaterializedPlatform)
Put implements MaterializeCache.
type MaterializeCache ¶
type MaterializeCache interface {
// Get returns the cached platform for key and whether it was present.
Get(key string) (*materialize.MaterializedPlatform, bool)
// Put stores mp under key, evicting per the implementation's policy.
Put(key string, mp *materialize.MaterializedPlatform)
}
MaterializeCache memoizes materialized platforms by a caller-derived key (see Key). Implementations MUST be safe for concurrent use.