Table of Contents

Interface IPortrayalInstructionCache

Namespace
EncDotNet.S100.Pipelines.Vector.Caching
Assembly
EncDotNet.S100.Core.dll

Caches the post-pipeline S-100 Part 9 drawing-instruction list produced for a dataset so that re-opening (or reloading) a previously-portrayed dataset can skip the expensive portrayal run. For S-101 the portrayal run is the MoonSharp execution of the Part 9A Lua rules, which dominates cold-load wall time (~1 s per cell); the rest of the load — ISO 8211 parse, layer build, paint — is comparatively cheap.

public interface IPortrayalInstructionCache

Remarks

The cached artifact is the fully-prepared DrawingInstruction list as it leaves PortrayalPipeline.ProcessAsync — i.e. after parsing, anchor resolution, transforms, viewing-group / display-plane filtering, and the S-100 Part 9 priority sort. Caching at this boundary (rather than the raw Lua-emitted instruction strings) means a hit reproduces the exact list a fresh run would, without re-implementing or bypassing any post-Lua stage. Everything the S-101 processor does after this point (the area / non-area split, the pattern-fill clip, the out-of-scale-band cap) runs downstream of the cached list and is therefore unaffected.

Correctness depends entirely on the key the caller supplies: it must fully identify every input that can change the emitted list — the dataset content, the feature- and portrayal-catalogue content (including any runtime overrides), the portrayal engine / rule version, and the mariner + ECDIS display state. The same key must always map to the same list. See S101DatasetProcessor's portrayal-content scope for the concrete key construction.

The abstraction mirrors IPatternClipCache so an in-memory implementation (InMemoryPortrayalInstructionCache, for tests and single-session reuse) and a disk-backed implementation (DiskPortrayalInstructionCache, which also survives process restart) fit behind one contract.

Properties

Hits

Number of GetOrCompute(string, Func<IReadOnlyList<DrawingInstruction>>) calls served from the cache (the portrayal run was skipped). Exposed for diagnostics and tests.

long Hits { get; }

Property Value

long

Misses

Number of GetOrCompute(string, Func<IReadOnlyList<DrawingInstruction>>) calls that ran the factory (cache miss). Exposed for diagnostics and tests.

long Misses { get; }

Property Value

long

Methods

GetOrCompute(string, Func<IReadOnlyList<DrawingInstruction>>)

Returns the cached drawing-instruction list for key, invoking factory to compute and store it on a miss.

IReadOnlyList<DrawingInstruction> GetOrCompute(string key, Func<IReadOnlyList<DrawingInstruction>> factory)

Parameters

key string

An opaque key that fully identifies the portrayal inputs (see the type remarks). The same key must always map to the same instruction list.

factory Func<IReadOnlyList<DrawingInstruction>>

Runs the portrayal pipeline to produce the instruction list when the key is not cached. Only invoked on a miss.

Returns

IReadOnlyList<DrawingInstruction>

The drawing-instruction list, in the same order as produced by the pipeline (the order is significant: it is the renderer's final priority tie-breaker). On a disk-cache hit the returned instances are freshly deserialized but value-equivalent to the originals.

GetOrComputeAsync(string, Func<CancellationToken, ValueTask<IReadOnlyList<DrawingInstruction>>>, CancellationToken)

Async counterpart to GetOrCompute(string, Func<IReadOnlyList<DrawingInstruction>>). Used by callers that drive the portrayal pipeline asynchronously (the standard render path) so the factory can await instead of blocking.

ValueTask<IReadOnlyList<DrawingInstruction>> GetOrComputeAsync(string key, Func<CancellationToken, ValueTask<IReadOnlyList<DrawingInstruction>>> factory, CancellationToken cancellationToken = default)

Parameters

key string
factory Func<CancellationToken, ValueTask<IReadOnlyList<DrawingInstruction>>>
cancellationToken CancellationToken

Returns

ValueTask<IReadOnlyList<DrawingInstruction>>