TPDFByteRangeCacheStats

Document management, Performance, Concurrency

Description

TPDFByteRangeCacheStats is the value returned by TByteRangeStream.GetCacheStats: one consistent snapshot of the cache configuration, its current occupancy and the cumulative traffic counters. It is a plain record, so a copy can be stored or logged without being affected by later cache activity.

GetRangeSourceCacheInfo serialises the same fields to JSON for a loaded document, and ClearRangeSourceCache resets the counters through ClearCache.

Syntax

Delphi

TPDFByteRangeCacheStats = Record
  WindowCount: Integer;
  PendingRequests: Integer;
  CacheLimitBytes: Int64;
  CachedBytes: Int64;
  CoalesceWindowMS: Cardinal;
  Hits: Int64;
  Misses: Int64;
  Evictions: Int64;
  SourceReads: Int64;
  SourceBytes: Int64;
  RepeatedReads: Int64;
  CoalescedRequests: Int64;
  CoalescedSourceReads: Int64;
End;

Fields

WindowCountNumber of chunks currently retained in the cache
PendingRequestsChunk fetch requests queued or in flight, including requests already being served by a source call
CacheLimitBytesByte budget applied by the least-recently-used eviction policy
CachedBytesSum of the retained chunk bytes
CoalesceWindowMSDelay the first caller to miss a chunk waits so that adjacent requests can be merged
HitsChunk reads served from the cache
MissesChunk reads that started a new fetch
EvictionsChunks dropped to stay within the budget or after the limit was reduced
SourceReadsCalls issued to the source for chunk data
SourceBytesBytes returned by those source calls
RepeatedReadsChunk fetches for a region fetched earlier since the counters were last reset, that is data fetched again after eviction
CoalescedRequestsRequests served by an existing pending fetch or merged into a shared source read
CoalescedSourceReadsSource reads that carried two or more chunk requests

Remarks

The snapshot is taken under the cache lock, performs no source I/O and changes no cache state, so it can be polled from a monitoring thread.

ClearCache(True) zeroes the counters and the fetched-range history behind RepeatedReads; ClearCache(False) drops chunks but keeps the counters.

CachedBytes stays within CacheLimitBytes because eviction runs after every insertion, while WindowCount reports how many chunks that budget currently holds.

See also

GetCacheStats, TByteRangeStream, ClearRangeSourceCache, GetRangeSourceCacheInfo, SetRangeSourceCacheLimit