Table of Contents

Class PortrayalAssetCache

Namespace
EncDotNet.S100.Portrayals
Assembly
EncDotNet.S100.Portrayals.dll

Default IPortrayalAssetCache implementation backed by ConcurrentDictionary<TKey, TValue> instances.

public sealed class PortrayalAssetCache : IPortrayalAssetCache
Inheritance
PortrayalAssetCache
Implements
Inherited Members

Remarks

Thread-safety: the per-asset slots are ConcurrentDictionary<TKey, TValue> instances, so two or more dataset pipelines rendering in parallel against catalogues for the same spec (a single shared cache) can read and write them concurrently without corrupting their internal state. The catalogues' load logic is idempotent — a concurrent miss may load the same asset more than once, with last-writer-wins — which is acceptable because the decoded asset is value-equivalent regardless of which thread produced it. This implements the hardening tracked by PR-6 of the asset-caching audit (docs/internal/asset-caching-audit.md §6 PR-6).

Palette loading remains serialized through PaletteLoadGate and PalettesLoaded; the palette slot keeps a plain dictionary because its concrete-typed view is part of the protected GmlPortrayalCatalogueBase.LoadPalettes API.

The LuaSources dictionary uses OrdinalIgnoreCase to preserve PR-2's case-insensitive lookup semantics (Lua require name lookups from MoonSharp are case-insensitive on Windows-style fs).

Properties

AreaFills

Cache of parsed area fills keyed by area-fill id. Populated on first call to GetAreaFill.

public IDictionary<string, AreaFill> AreaFills { get; }

Property Value

IDictionary<string, AreaFill>

CompiledXslt

Cache of compiled XSLT transforms keyed by rule name. Populated on first call to GetCompiledRule.

public IDictionary<string, XslCompiledTransform> CompiledXslt { get; }

Property Value

IDictionary<string, XslCompiledTransform>

LineStyles

Cache of parsed line styles keyed by line-style id. Populated on first call to GetLineStyle.

public IDictionary<string, LineStyle> LineStyles { get; }

Property Value

IDictionary<string, LineStyle>

LuaScripts

Cache of compiled Lua Script instances keyed by script name. Populated on first call to GetLuaScript.

public IDictionary<string, Script> LuaScripts { get; }

Property Value

IDictionary<string, Script>

LuaSources

Cache of raw Lua source strings keyed (case-insensitively) by bare file name. A cached null records a negative lookup so missing-module require() calls do not re-open the asset source on every miss (see PR-2 of the asset-caching audit).

public IDictionary<string, string?> LuaSources { get; }

Property Value

IDictionary<string, string>

PaletteLoadGate

Serializes the one-shot palette load across catalogues that share this cache. Multiple datasets of the same spec (for example, every cell of one S-101 exchange set) load on separate threads but share a single per-spec cache; without this gate they would race to populate the non-thread-safe palette dictionary or observe it half-populated. See issue #321.

public SemaphoreSlim PaletteLoadGate { get; }

Property Value

SemaphoreSlim

Palettes

Cache of loaded colour palettes keyed by palette type (Day/Dusk/Night). Populated together by the catalogue's palette scan; the scan happens once per cache (see PalettesLoaded).

public IDictionary<PaletteType, ColorPalette> Palettes { get; }

Property Value

IDictionary<PaletteType, ColorPalette>

PalettesLoaded

Sticky flag set by the catalogue once it has performed the one-shot scan of Catalogue.ColorProfiles that populates Palettes. When two catalogues share a cache this flag prevents the second catalogue from re-running the scan (and re-opening the underlying colour-profile assets).

public bool PalettesLoaded { get; set; }

Property Value

bool

Symbols

Cache of parsed SVG symbols keyed by symbol id. Populated on first call to GetSymbol.

public IDictionary<string, SvgSymbol> Symbols { get; }

Property Value

IDictionary<string, SvgSymbol>