Interface IDatasetMetadataCache
A cross-session cache of DatasetMetadata keyed by a dataset's source file identity, letting a host recover a dataset's cheap "peek" facts (spec, extent, CRS, display-scale window, temporal coverage) without re-parsing the dataset — including after a process restart (issue #467 WS3).
public interface IDatasetMetadataCache
Remarks
The cache is the enabler for the relaxed parse-once rule: a persisted metadata entry is what makes "cheap metadata parse now, full render parse later" pay off, and it is the primary enabler of loose-dataset lazy registration. A hit means zero parse on subsequent sessions.
Correctness rests on the key: an entry is valid only while the source file's last-write time and length are unchanged. Any mismatch — or a serialization-format bump, or a corrupt entry — is a miss, and a miss must never break loading (the producer still runs).
Properties
Hits
Number of reads served from a valid cached entry.
long Hits { get; }
Property Value
Misses
Number of lookups (via either GetOrRead(string, Func<string, DatasetMetadata>) or TryGet(string, out DatasetMetadata)) not served from a valid cached entry. In GetOrRead(string, Func<string, DatasetMetadata>) such a miss is where the producer runs; in TryGet(string, out DatasetMetadata) it simply returns false.
long Misses { get; }
Property Value
Methods
GetOrRead(string, Func<string, DatasetMetadata>)
Returns the cached metadata for sourcePath when a
valid entry exists (source unchanged since it was written), otherwise
invokes producer, persists its result, and returns
it. A cache failure never propagates: the freshly produced value is
still returned.
DatasetMetadata GetOrRead(string sourcePath, Func<string, DatasetMetadata> producer)
Parameters
sourcePathstringAbsolute path to the dataset file whose metadata is cached. Its last-write time and length form the validity key.
producerFunc<string, DatasetMetadata>Cold path invoked on a miss to parse the metadata from
sourcePath. Receives the same path.
Returns
- DatasetMetadata
The cached or freshly produced metadata.
TryGet(string, out DatasetMetadata)
Attempts to read a valid cached entry for sourcePath
without producing on a miss. Useful for a pure "is it already known?"
probe.
bool TryGet(string sourcePath, out DatasetMetadata metadata)
Parameters
sourcePathstringAbsolute path to the dataset file.
metadataDatasetMetadataThe cached metadata when the method returns true.