pub struct CompressionCache { /* private fields */ }Expand description
Compression cache implementation.
Implementations§
Source§impl CompressionCache
impl CompressionCache
pub fn new(config: CacheConfig) -> Self
Sourcepub fn get(&mut self, message: &Message) -> Option<&CacheEntry>
pub fn get(&mut self, message: &Message) -> Option<&CacheEntry>
Check if a message is in the cache.
Sourcepub fn put(&mut self, original: &Message, compressed: Message)
pub fn put(&mut self, original: &Message, compressed: Message)
Add a compressed message to the cache.
Sourcepub fn evict_expired(&mut self)
pub fn evict_expired(&mut self)
Evict expired entries.
Sourcepub fn stats(&self) -> &CacheStats
pub fn stats(&self) -> &CacheStats
Get cache statistics.
Sourcepub fn record_token_savings(&mut self, tokens: u32)
pub fn record_token_savings(&mut self, tokens: u32)
Record token savings from cache hit.
Trait Implementations§
Source§impl Debug for CompressionCache
impl Debug for CompressionCache
Auto Trait Implementations§
impl Freeze for CompressionCache
impl RefUnwindSafe for CompressionCache
impl Send for CompressionCache
impl Sync for CompressionCache
impl Unpin for CompressionCache
impl UnsafeUnpin for CompressionCache
impl UnwindSafe for CompressionCache
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