pub struct S3FifoWidthCache { /* private fields */ }Expand description
Width cache backed by S3-FIFO eviction (bd-l6yba.2).
Drop-in replacement for WidthCache that uses the scan-resistant
S3-FIFO eviction policy instead of LRU. This protects frequently-used
width entries from being evicted by one-time scan patterns (e.g. when a
large block of new text scrolls past).
Uses the same 64-bit FxHash keying as WidthCache with a secondary
FNV fingerprint for collision detection.
Implementations§
Source§impl S3FifoWidthCache
impl S3FifoWidthCache
Sourcepub fn with_default_capacity() -> Self
pub fn with_default_capacity() -> Self
Create a new cache with the default capacity (4096 entries).
Sourcepub fn get_or_compute(&mut self, text: &str) -> usize
pub fn get_or_compute(&mut self, text: &str) -> usize
Get cached width or compute and cache it.
Sourcepub fn get_or_compute_with<F>(&mut self, text: &str, compute: F) -> usize
pub fn get_or_compute_with<F>(&mut self, text: &str, compute: F) -> usize
Get cached width or compute using a custom function.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset statistics.
Trait Implementations§
Source§impl Debug for S3FifoWidthCache
impl Debug for S3FifoWidthCache
Auto Trait Implementations§
impl Freeze for S3FifoWidthCache
impl RefUnwindSafe for S3FifoWidthCache
impl Send for S3FifoWidthCache
impl Sync for S3FifoWidthCache
impl Unpin for S3FifoWidthCache
impl UnwindSafe for S3FifoWidthCache
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