Cache Infrastructure

HotPDF provides a bounded weighted memory cache for reusable intermediate objects and a persistent rendered-page cache used by loaded-document rendering

Weighted memory cache

THPDFWeightedCache in HPDFCache owns TObject values, indexes them by AnsiString, and evicts the least recently used values until their combined weight fits MaxBytes

Content keys

function HPDFCacheKeyOfBytes(const Bytes: TBytes): AnsiString;
function HPDFCacheKeyOfStream(Stream: TStream): AnsiString;

Both functions return the same lowercase SHA-256 hexadecimal key for the same content

HPDFCacheKeyOfStream hashes without allocating a second full-size byte array, reads seekable streams from position zero, and restores their original position

Persistent rendered-page cache

Set THotPDF.RenderCacheFolder to enable the disk tier used after the in-memory rendered-page cache

Sharded loaded-image decode cache

Each THotPDF instance coordinates loaded-image decode reuse through 16 independently locked metadata shards

ICC transform cache

HPDFICC shares complete source-to-sRGB transforms through a thread-safe 64 MiB weighted LRU cache, including proof and output profiles when configured

Persistent font-subset cache

Set THotPDF.FontSubsetCacheFolder to enable reusable TrueType and OpenType subset results while EnableFontSubsetting is active

PDF.EnableFontSubsetting := True;
PDF.FontSubsetCacheFolder := 'C:\ProgramData\MyApp\HotPDF\FontSubsets';
PDF.FontSubsetCacheMaxBytes := 256 * 1024 * 1024;

Persistent rendered-page cache

Set THotPDF.RenderCacheFolder to enable the disk tier used after the in-memory rendered-page cache

Ownership

Related APIs