Struct TileCacheSettings
Disk tile cache configuration. Validated at construction so illegal combinations cannot reach the store.
public readonly struct TileCacheSettings
- Inherited Members
Remarks
MaxDataBytes is the live-index cap, not the file size. Evicted blobs stay on disk until compaction; MaxFileBytes is the file bound. ProtectedMaxBytes is a reservation for coarse tiles, not a ceiling: they may fill the whole cache when nothing else is stored.
Constructors
TileCacheSettings(long, double, long, int, long, long)
Builds a validated cache configuration.
public TileCacheSettings(long maxDataBytes, double compactWasteRatio = 0.5, long protectedMaxBytes = 33554432, int protectedMaxZoom = 8, long wasteAllowanceCeiling = 1073741824, long inlineCompactMaxBytes = 1073741824)
Parameters
maxDataByteslongLive-data cap in bytes; must be positive.
compactWasteRatiodoubleSecondary compaction trigger as a fraction of file size, in [0, 1]. 0 rewrites on any waste; 1 disables only this trigger.
protectedMaxByteslongRequested reservation in bytes for tiles at or below
protectedMaxZoom; clamped to halfmaxDataBytes. 0 disables the tier.protectedMaxZoomintHighest integer tile zoom in the protected tier, in 0..28.
wasteAllowanceCeilinglongCap on orphaned-blob allowance in bytes; must be positive.
inlineCompactMaxByteslongLive-set size in bytes above which automatic compaction is deferred.
Fields
DefaultInlineCompactMaxBytes
Default InlineCompactMaxBytes: 1 GiB.
public const long DefaultInlineCompactMaxBytes = 1073741824
Field Value
DefaultWasteAllowanceCeiling
Default cap on orphaned-blob allowance: 1 GiB.
public const long DefaultWasteAllowanceCeiling = 1073741824
Field Value
Properties
CompactWasteRatio
Secondary compaction trigger as a fraction of file size, in [0, 1]. 0 rewrites on any waste; 1 disables only this trigger.
public double CompactWasteRatio { get; }
Property Value
Default
Library default: 256 MiB, sized for a phone.
public static TileCacheSettings Default { get; }
Property Value
DesktopLarge
Desktop and editor default: 10 GiB.
public static TileCacheSettings DesktopLarge { get; }
Property Value
InlineCompactMaxBytes
Live-set size in bytes above which automatic compaction is deferred to CompactNow().
public long InlineCompactMaxBytes { get; }
Property Value
MaxDataBytes
Cap on bytes reachable through the index, in bytes. Evicted blobs stay in the file until compaction.
public long MaxDataBytes { get; }
Property Value
MaxFileBytes
Longest the packed file may get before writes are refused, in bytes.
public long MaxFileBytes { get; }
Property Value
Minimap
Small cache for a minimap: 24 MiB.
public static TileCacheSettings Minimap { get; }
Property Value
ProtectedMaxBytes
Bytes of the cap reserved for tiles at or below ProtectedMaxZoom. A reservation, not a ceiling; 0 disables the tier.
public long ProtectedMaxBytes { get; }
Property Value
ProtectedMaxZoom
Highest integer tile zoom that counts as protected. Default 8.
public int ProtectedMaxZoom { get; }
Property Value
WasteAllowanceBytes
Room for orphaned blobs between the live cap and the file bound, in bytes.
public long WasteAllowanceBytes { get; }
Property Value
Methods
FromMegabytes(int)
Builds settings from a megabyte count, clamping a forgotten 0 to 1 MiB instead of throwing.
public static TileCacheSettings FromMegabytes(int megabytes)
Parameters
megabytesintLive-data cap in mebibytes (1024 * 1024 bytes).
Returns
- TileCacheSettings
Settings with that cap, at least 1 MiB.
IsProtectedZoom(int)
True when a tile at zoom belongs in the protected eviction tier.
public bool IsProtectedZoom(int zoom)
Parameters
zoomintInteger tile zoom.
Returns
- bool
True when the reservation is enabled and zoom is in 0..ProtectedMaxZoom.
ShouldCompact(long, long)
Whether the packed file has enough orphaned bytes to be worth rewriting.
public bool ShouldCompact(long fileLength, long liveBytes)
Parameters
Returns
- bool
True when waste exceeds half the allowance or CompactWasteRatio of the file.
WithMaxDataBytes(long)
Same configuration at a different live-data cap. The protected reservation is re-clamped against the new cap.
public TileCacheSettings WithMaxDataBytes(long maxDataBytes)
Parameters
maxDataByteslongNew live-data cap in bytes; must be positive.
Returns
- TileCacheSettings
A new settings value; this one is unchanged.