Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Class SliceCache

    SliceCache — byte-budget LRU of decoded per-slice geometry.

    Key format: ${nodePath}\u0000${viewSig} (see SliceCache.makeKey), where viewSig is a stable serialization of the query's displayDims / slicePosition / tolerance / dimensions — the loader's viewStatesEqual fields, ALL of them (a key narrower than that equality can restore a snapshot the loader itself would have reloaded; see data/loaders/progressive/slice-cache-helper.ts::buildSliceViewSig).

    Index
    MAX_TOMBSTONES: 4096

    Tombstone cap — bounded so long sessions can't grow it unboundedly.

    debug: boolean
    maxSize: number
    tombstones: Set<string> = ...
    thrashMisses: number = 0
    oversizedWarned: Set<string> = ...
    ladderDepths: Map<string, { depth: number; totalDepth: number }> = ...
    • Default cache size derived from config.cache.sliceCacheMaxSizeMB. A method, not a static initializer: reading config at module-load time couples every transitive importer (e.g. the shared facade helpers) to a fully-populated config mock in tests.

      Returns number

    • Cache a per-slice entry (may evict entries to stay within budget).

      Parameters

      • key: string

        Cache key (use SliceCache.makeKey).

      • entry: SliceCacheEntry

        Cloned payload + its retained byte size.

      • Optionalopts: { scan?: boolean; pin?: boolean }
        • Optionalscan?: boolean

          The caller KNOWS it is storing inside a sequential scan (dimension playback: the loaders pass frameBudgetMs !== null). Evicts from the MRU end instead of LRU — scan-resistant eviction that keeps the loop-head prefix resident across cyclic loops (see LRUCache.set). Known trade-off: under bounce loop mode near a turnaround this is locally worse than LRU (the loaders only see the budget directive, not the loop mode) — accepted; a loop-mode-aware per-pass hint is a possible follow-up.

        • Optionalpin?: boolean

          Protect this entry from eviction until it is next read (unpinned on the first get hit). The SlicePrefetcher sets it so a projected next-frame slice — which lands as the MRU entry and would be the FIRST victim of a subsequent scan store under budget pressure — survives until the foreground tick restores it. Best-effort: if the whole working set is pinned and over budget, pinned entries are still evicted.

      Returns void

    • Check whether a slice is cached (without LRU promotion).

      Parameters

      • key: string

      Returns boolean

    • Read an entry WITHOUT LRU promotion and WITHOUT counting a hit/miss. Used by storeLadder's upgrade-if-longer check so bookkeeping reads don't perturb the hit-rate statistic the monitor reports.

      Parameters

      • key: string

      Returns SliceCacheEntry | undefined

    • Remove one cached slice without leaving an eviction tombstone.

      Parameters

      • key: string

        Cache key to invalidate.

      Returns boolean

      Whether an entry was removed.

    • Whether an entry of bytes could ever be stored (i.e. it does not exceed the whole budget). The LRU silently rejects oversized entries, so callers check this BEFORE doing the (potentially large) clone to avoid a wasted copy that would just be dropped — see storeLadder.

      Parameters

      • bytes: number

      Returns boolean

    • Warn-once gate for oversized ladders: returns true the FIRST time key is reported oversized (a full ladder exceeding the whole budget, so only a coarse prefix is cached — see storeLadder), false thereafter. Bounded FIFO + cleared on clear, so warnings can't leak across a long session or a dataset switch (mirrors the tombstone discipline).

      Parameters

      • key: string

      Returns boolean

    • Clear all cached slices (invoked on content-hash / dataset invalidation).

      Returns void

    • Record an evicted key as a tombstone (bounded FIFO).

      Parameters

      • key: string

      Returns void

    • Build a cache key from a node path and a view signature.

      The NUL separator can't appear in a node path or the JSON-ish view signature, so the two are always unambiguously recoverable.

      Parameters

      • nodePath: string

        Scene-graph path of the geometry node (per-node namespace).

      • viewSig: string

        Stable serialization of the query view (slice/tolerance/displayDims).

      Returns string