PdfPageObjectCache<V> class

A bounded, least-recently-used cache keyed by page index.

The viewer derives a few objects per page - extracted text, the interactive and visible annotation lists, the form-field rects - and keeps them so a re-visit (a scroll back, a hit-test, a search) does not recompute. The cap sits well above the on-screen plus preview-warm working set (a page's objects are derived only when it is near the viewport - hit-tested, selected or searched), so ordinary back-and-forth revisits still hit; it only stops the cold tail from growing without limit on a long document.

Insertion order is LRU order: a plain Dart map is insertion-ordered, so its first key is the least-recently used, and a remove-then-reinsert on access moves an entry to the most-recently-used end (the technique the render worker's record cache uses). A lookup or insert therefore marks its page most-recently used, so a page in view is never the eviction victim.

V is expected to be non-nullable - a stored null reads back as a miss.

Constructors

PdfPageObjectCache({int? maxEntries})

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
The number of retained entries. Bounded by the configured cap.
no setter
pages Iterable<int>
The retained pages, least-recently used first.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Drops every entry - a document or revision swap invalidates them all.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
putIfAbsent(int page, V ifAbsent()) → V
The cached value for page, computing and storing it with ifAbsent on a miss. The entry is marked most-recently used, then the least-recently used entries past the cap are evicted (never the entry just inserted - it is the most-recently used).
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](int page) → V?
The cached value for page, or null on a miss. A hit is marked most-recently used so a lookup protects the entry from eviction.