pub struct LruParseCache { /* private fields */ }Expand description
LRU parse cache with configurable size limit.
Thread-safe implementation using RwLock for the main cache and atomics for statistics.
Implementations§
Source§impl LruParseCache
impl LruParseCache
Sourcepub fn new(max_entries: usize) -> Self
pub fn new(max_entries: usize) -> Self
Create a new cache with the specified maximum entries.
A good default is 10,000 entries, which at ~1KB per entry uses about 10MB of memory.
Sourcepub fn with_options(max_entries: usize, reader_eviction_enabled: bool) -> Self
pub fn with_options(max_entries: usize, reader_eviction_enabled: bool) -> Self
Create a new cache with configurable options.
§Arguments
max_entries- Maximum number of entries to cachereader_eviction_enabled- If true, entries are evicted when all readers have passed them. If false, only LRU eviction is used.
Sourcepub fn get_stats(&self) -> CacheStats
pub fn get_stats(&self) -> CacheStats
Get current cache statistics.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics counters (keeps cache contents).
Trait Implementations§
Source§impl Debug for LruParseCache
impl Debug for LruParseCache
Source§impl ParseCache for LruParseCache
impl ParseCache for LruParseCache
Source§fn get(&self, frame_number: u64) -> Option<Arc<CachedParse>>
fn get(&self, frame_number: u64) -> Option<Arc<CachedParse>>
Get cached parse result for a frame, if available.
Source§fn reset_stats(&self)
fn reset_stats(&self)
Reset statistics counters. Default implementation does nothing.
Source§fn reader_passed(&self, reader_id: usize, frame_number: u64)
fn reader_passed(&self, reader_id: usize, frame_number: u64)
Hint that a reader has finished with frames up to this number. Read more
Source§fn register_reader(&self) -> usize
fn register_reader(&self) -> usize
Register a new reader and get its ID.
Source§fn unregister_reader(&self, reader_id: usize)
fn unregister_reader(&self, reader_id: usize)
Unregister a reader (e.g., when stream completes).
Source§fn stats(&self) -> Option<CacheStats>
fn stats(&self) -> Option<CacheStats>
Get cache statistics (if available).
Source§fn get_or_insert_with(
&self,
frame_number: u64,
f: Box<dyn FnOnce() -> Arc<CachedParse> + '_>,
) -> (Arc<CachedParse>, bool)
fn get_or_insert_with( &self, frame_number: u64, f: Box<dyn FnOnce() -> Arc<CachedParse> + '_>, ) -> (Arc<CachedParse>, bool)
Get cached result or compute and cache it. Returns (result, was_hit).
Auto Trait Implementations§
impl !Freeze for LruParseCache
impl RefUnwindSafe for LruParseCache
impl Send for LruParseCache
impl Sync for LruParseCache
impl Unpin for LruParseCache
impl UnwindSafe for LruParseCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more