Table of Contents

Class InMemoryPatternClipCache

Namespace
EncDotNet.S100.Renderers.Mapsui
Assembly
EncDotNet.S100.Renderers.Mapsui.dll

In-memory, single-slot IPatternClipCache: it remembers only the most recently computed key and its clipped pattern geometry.

public sealed class InMemoryPatternClipCache : IPatternClipCache
Inheritance
InMemoryPatternClipCache
Implements
Inherited Members

Remarks

A single slot bounds memory (one cell's clip geometry can be large) while still capturing the dominant reuse pattern — repeatedly re-rendering the same dataset under different palettes. It mirrors the S101DatasetProcessor's existing single-entry _cachedPortrayalInstructions cache of the rule output.

The disk-backed DiskPatternClipCache retains multiple cells and survives process restarts behind the same IPatternClipCache contract; this implementation deliberately keeps the in-process footprint to a single cell.

Instances are thread-safe. Concurrent misses may duplicate the same computation, but the last identical result becomes the retained entry.

Properties

Hits

Number of GetOrCompute(string, Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>>) calls served from the cache (the expensive clip overlay was skipped). Exposed for diagnostics and tests.

public long Hits { get; }

Property Value

long

Misses

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

public long Misses { get; }

Property Value

long

Methods

GetOrCompute(string, Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>>)

Returns the cached clipped pattern geometry for key, invoking factory to compute and store it on a miss.

public IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)> GetOrCompute(string key, Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>> factory)

Parameters

key string

An opaque key that fully identifies the clip inputs (for S-101 this is the mariner + ECDIS display-state portrayal cache key). The same key must always map to the same clip result.

factory Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>>

Computes the clipped pattern geometry when the key is not cached. Only invoked on a miss.

Returns

IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>

The clipped pattern entries, each carrying its palette-independent pattern reference, drawing priority, and clipped geometry. On a hit the exact cached instances are returned.