THotPDF Cache Admission Policies

Controls cache admission independently for raw compressed source ranges, decoded images, compiled page display lists, and rendered raster pages

اعلانها

THPDFCacheLayerKind = (clkRawCompressed, clkDecoded,
  clkDisplayList, clkRaster);

THPDFCacheAdmissionPolicy = record
  Enabled: boolean;
  AdaptiveAdmission: boolean;
  MaxEntries: Integer;
  MaxTotalBytes: Int64;
  MaxEntryBytes: Int64;
end;

THPDFCacheAdmissionStatistics = record
  Enabled: boolean;
  AdaptiveAdmission: boolean;
  MaxEntries: Integer;
  MaxTotalBytes: Int64;
  MaxEntryBytes: Int64;
  EntryCount: Integer;
  CurrentBytes: Int64;
  HitCount: Int64;
  MissCount: Int64;
  AdmissionCount: Int64;
  RejectionCount: Int64;
  EvictionCount: Int64;
  FrequencyAdmissionCount: Int64;
  FrequencyRejectionCount: Int64;
  FrequencyAgingCount: Int64;
end;

procedure ResetCacheAdmissionPolicies;
procedure SetCacheAdmissionPolicy(Kind: THPDFCacheLayerKind;
  const Policy: THPDFCacheAdmissionPolicy);
function GetCacheAdmissionPolicy(Kind: THPDFCacheLayerKind;
  out Policy: THPDFCacheAdmissionPolicy): boolean;
function GetCacheAdmissionStatistics(Kind: THPDFCacheLayerKind;
  out Statistics: THPDFCacheAdmissionStatistics): boolean;

Default limits

LayerEntriesTotal bytesPer entryAdaptive
clkRawCompressed82 MiB256 KiBYes
clkDecoded25632 MiB16 MiBYes
clkDisplayList6464 MiB16 MiBYes
clkRaster8128 MiB64 MiBYes

Admission behaviour

An enabled policy requires positive entry, total-byte, and per-entry limits, and the per-entry limit must not exceed the total-byte limit

Changing one layer never changes another layer, and lowering a limit immediately removes least-recently-used entries until the affected cache fits

With AdaptiveAdmission enabled, least-recently-used order remains the fast recency path while a four-way bounded frequency sketch compares a new candidate with every required victim before eviction

A colder candidate bypasses retention without disturbing the current request, equal frequency favours the newer candidate, and periodic counter aging lets a changed working set replace historical hot entries

Set AdaptiveAdmission to False to retain the same hard bounds with pure least-recently-used admission

Entries larger than MaxEntryBytes are used for the current operation but bypass retention, preventing one large decoded image, display list, or rendered page from displacing reusable smaller entries

Setting Enabled to False with zero limits disables retention for that layer, while ResetCacheAdmissionPolicies restores all four defaults

Statistics

THPDFCacheAdmissionStatistics returns the active limits, adaptive mode, current entry and byte occupancy, hits, misses, accepted admissions, rejected admissions, capacity evictions, frequency decisions, and aging cycles

Raw-range statistics describe the automatic coalescing source created by LoadFromRandomAccessSource; an explicitly supplied THPDFCoalescingRandomAccessSource retains its caller-selected configuration

Compatibility properties

RenderCacheCapacity updates the raster entry limit and ImageCacheMaxBytes updates the decoded-image total-byte limit through the same policy validation and immediate trimming path

See also: Scalable Loading, THPDFCoalescingRandomAccessSource, LoadFromRandomAccessSource