pub struct FragmentPool { /* private fields */ }Expand description
Fragment pool for pre-warmed fragments
Implementations§
Source§impl FragmentPool
impl FragmentPool
Sourcepub fn new(config: PoolConfig) -> Self
pub fn new(config: PoolConfig) -> Self
Create new pool
Sourcepub fn get_or_create<F>(&self, key: &str, create_fn: F) -> Result<Arc<Vec<u8>>>
pub fn get_or_create<F>(&self, key: &str, create_fn: F) -> Result<Arc<Vec<u8>>>
Get or create fragment
Sourcepub fn insert(&self, key: impl Into<String>, data: Vec<u8>) -> Result<()>
pub fn insert(&self, key: impl Into<String>, data: Vec<u8>) -> Result<()>
Insert fragment directly
Sourcepub fn remove(&self, key: &str) -> Option<PooledFragment>
pub fn remove(&self, key: &str) -> Option<PooledFragment>
Remove fragment
Sourcepub fn clear_expired(&self) -> usize
pub fn clear_expired(&self) -> usize
Clear expired fragments
Sourcepub fn total_size(&self) -> u64
pub fn total_size(&self) -> u64
Total size
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FragmentPool
impl !RefUnwindSafe for FragmentPool
impl Send for FragmentPool
impl Sync for FragmentPool
impl Unpin for FragmentPool
impl UnwindSafe for FragmentPool
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