TokenCache class

A bounded least-recently-used cache from a tokenize key to its List<List<ThemedToken>> result.

Eviction is dual-bounded: entries are dropped oldest-first until both maxEntries and maxChars (the summed length of cached source) are satisfied. The char bound keeps a few large files from dominating memory.

Constructors

TokenCache({int maxEntries = 64, int maxChars = 4 * 1024 * 1024})
Creates a TokenCache bounded by maxEntries and maxChars.

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
The current number of cached entries.
no setter
maxChars int
The maximum summed source length (in characters) of cached entries before oldest ones are evicted.
final
maxEntries int
The maximum number of cached entries before oldest ones are evicted.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Removes all cached entries.
contains(String key) bool
Whether key is currently cached. Does not affect recency ordering.
get(String key) List<List<ThemedToken>>?
The cached tokens for key, or null. A hit marks key most-recently-used.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(String key, List<List<ThemedToken>> tokens, int chars) → void
Stores tokens for key, evicting oldest entries until within bounds. chars is the source length used for the maxChars budget.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

keyFor(String code, TokenizeOptions options) String
The tokenize inputs that affect the resulting tokens, as a single key.