Struct torrust_index_backend::cache::BytesCache
source · pub struct BytesCache { /* private fields */ }
Implementations§
source§impl BytesCache
impl BytesCache
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
pub fn with_entry_size_limit(entry_size_limit: usize) -> Self
sourcepub fn with_capacity_and_entry_size_limit(
capacity: usize,
entry_size_limit: usize
) -> Result<Self, Error>
pub fn with_capacity_and_entry_size_limit( capacity: usize, entry_size_limit: usize ) -> Result<Self, Error>
Helper to create a new bytes cache with both an individual entry and size limit.
Errors
This function will return Error::EntrySizeLimitExceedsTotalCapacity
if the specified size is too large.
pub async fn get(&self, key: &str) -> Option<BytesCacheEntry>
pub async fn len(&self) -> usize
pub async fn is_empty(&self) -> bool
pub fn total_size(&self) -> usize
sourcepub async fn set(
&mut self,
key: String,
bytes: Bytes
) -> Result<Option<BytesCacheEntry>, Error>
pub async fn set( &mut self, key: String, bytes: Bytes ) -> Result<Option<BytesCacheEntry>, Error>
Adds a image to the cache.
Errors
This function will return an error if there is not enough free size.
pub fn pop(&mut self) -> Option<BytesCacheEntry>
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for BytesCache
impl Send for BytesCache
impl Sync for BytesCache
impl Unpin for BytesCache
impl UnwindSafe for BytesCache
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