Table of Contents

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

maxDataBytes long

Live-data cap in bytes; must be positive.

compactWasteRatio double

Secondary compaction trigger as a fraction of file size, in [0, 1]. 0 rewrites on any waste; 1 disables only this trigger.

protectedMaxBytes long

Requested reservation in bytes for tiles at or below protectedMaxZoom; clamped to half maxDataBytes. 0 disables the tier.

protectedMaxZoom int

Highest integer tile zoom in the protected tier, in 0..28.

wasteAllowanceCeiling long

Cap on orphaned-blob allowance in bytes; must be positive.

inlineCompactMaxBytes long

Live-set size in bytes above which automatic compaction is deferred.

Fields

DefaultInlineCompactMaxBytes

Default InlineCompactMaxBytes: 1 GiB.

public const long DefaultInlineCompactMaxBytes = 1073741824

Field Value

long

DefaultWasteAllowanceCeiling

Default cap on orphaned-blob allowance: 1 GiB.

public const long DefaultWasteAllowanceCeiling = 1073741824

Field Value

long

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

double

Default

Library default: 256 MiB, sized for a phone.

public static TileCacheSettings Default { get; }

Property Value

TileCacheSettings

DesktopLarge

Desktop and editor default: 10 GiB.

public static TileCacheSettings DesktopLarge { get; }

Property Value

TileCacheSettings

InlineCompactMaxBytes

Live-set size in bytes above which automatic compaction is deferred to CompactNow().

public long InlineCompactMaxBytes { get; }

Property Value

long

MaxDataBytes

Cap on bytes reachable through the index, in bytes. Evicted blobs stay in the file until compaction.

public long MaxDataBytes { get; }

Property Value

long

MaxFileBytes

Longest the packed file may get before writes are refused, in bytes.

public long MaxFileBytes { get; }

Property Value

long

Minimap

Small cache for a minimap: 24 MiB.

public static TileCacheSettings Minimap { get; }

Property Value

TileCacheSettings

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

long

ProtectedMaxZoom

Highest integer tile zoom that counts as protected. Default 8.

public int ProtectedMaxZoom { get; }

Property Value

int

WasteAllowanceBytes

Room for orphaned blobs between the live cap and the file bound, in bytes.

public long WasteAllowanceBytes { get; }

Property Value

long

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

megabytes int

Live-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

zoom int

Integer 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

fileLength long

Packed data file length in bytes.

liveBytes long

Bytes reachable through the index.

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

maxDataBytes long

New live-data cap in bytes; must be positive.

Returns

TileCacheSettings

A new settings value; this one is unchanged.