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
| WindowCount | Number of chunks currently retained in the cache |
|---|---|
| PendingRequests | Chunk fetch requests queued or in flight, including requests already being served by a source call |
| CacheLimitBytes | Byte budget applied by the least-recently-used eviction policy |
| CachedBytes | Sum of the retained chunk bytes |
| CoalesceWindowMS | Delay the first caller to miss a chunk waits so that adjacent requests can be merged |
| Hits | Chunk reads served from the cache |
| Misses | Chunk reads that started a new fetch |
| Evictions | Chunks dropped to stay within the budget or after the limit was reduced |
| SourceReads | Calls issued to the source for chunk data |
| SourceBytes | Bytes returned by those source calls |
| RepeatedReads | Chunk fetches for a region fetched earlier since the counters were last reset, that is data fetched again after eviction |
| CoalescedRequests | Requests served by an existing pending fetch or merged into a shared source read |
| CoalescedSourceReads | Source 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