pub struct TrieCache { /* private fields */ }Expand description
A thread-safe, byte-bounded cache of byte-tries keyed by vocabulary fingerprint. Read-mostly after warm-up; once the budget is reached, further tries are built and returned but not retained.
Implementations§
Source§impl TrieCache
impl TrieCache
Sourcepub fn with_budget(budget: usize) -> Self
pub fn with_budget(budget: usize) -> Self
An empty cache with an explicit retained-byte budget.
Sourcepub fn with_build_limit(budget: usize, max_concurrent_builds: usize) -> Self
pub fn with_build_limit(budget: usize, max_concurrent_builds: usize) -> Self
An empty cache with an explicit retained-byte budget and the default build gate.
Sourcepub fn with_build_gate(
budget: usize,
max_concurrent_builds: usize,
max_transient_build_bytes: usize,
) -> Self
pub fn with_build_gate( budget: usize, max_concurrent_builds: usize, max_transient_build_bytes: usize, ) -> Self
An empty cache with an explicit retained-byte budget, a concurrent-build count cap, AND a transient-build byte budget (so many large concurrent builds cannot exhaust memory).
Sourcepub fn peak_concurrent_builds(&self) -> usize
pub fn peak_concurrent_builds(&self) -> usize
The peak number of simultaneous distinct-vocabulary builds observed (for tests/telemetry).
Sourcepub fn peak_concurrent_build_bytes(&self) -> usize
pub fn peak_concurrent_build_bytes(&self) -> usize
The peak concurrent transient-build bytes charged (for tests/telemetry).
Sourcepub fn get_or_build_byte(
&self,
vocab: &Vocabulary,
) -> Result<Arc<VocabTrie>, CompileError>
pub fn get_or_build_byte( &self, vocab: &Vocabulary, ) -> Result<Arc<VocabTrie>, CompileError>
The cached byte-trie for vocab, building and inserting it on a miss. Two vocabularies with
equal fingerprints get the same Arc; the trie is built outside the lock, so a rare double
Sourcepub fn bind(
&self,
handle: &VocabularyHandle,
) -> Result<BoundByteTrie, CompileError>
pub fn bind( &self, handle: &VocabularyHandle, ) -> Result<BoundByteTrie, CompileError>
The byte-trie for handle’s vocabulary, wrapped as an opaque BoundByteTrie whose
fingerprint is guaranteed (by construction, not by caller honesty) to be handle’s own -
Sourcepub fn clear(&self)
pub fn clear(&self)
Drops every retained trie. Also clears the LRU touch-log, so repeated fill/clear cycles
cannot accumulate stale log records indefinitely. Traffic counters (stats()) are NOT reset -