Struct nebari::ChunkCache
source · [−]pub struct ChunkCache { /* private fields */ }Expand description
A configurable cache that operates at the “chunk” level.
While writing databases, individual portions of data are often written as a single chunk. These chunks may be stored encrypted on-disk, but the in-memory cache will be after decryption.
To keep memory usage low, the maximum size for a cached value can be set. It is important that this value be large enough to fit most B-Tree nodes, and that size will depend on how big the tree grows.
Implementations
sourceimpl ChunkCache
impl ChunkCache
sourcepub fn new(capacity: usize, max_chunk_length: usize) -> Self
pub fn new(capacity: usize, max_chunk_length: usize) -> Self
Create a new cache with a maximum number of entries (capacity) and
max_chunk_length. Any chunks longer than max_chunk_length will not
be cached. The maximum memory usage of this cache can be calculated as
capacity * max_chunk_length, although the actual memory usage will
likely be much smaller as many chunks are small.
sourcepub fn insert(&self, file_id: u64, position: u64, buffer: ArcBytes<'static>)
pub fn insert(&self, file_id: u64, position: u64, buffer: ArcBytes<'static>)
Adds a new cached chunk for file_path at position.
sourcepub fn replace_with_decoded<T: AnySendSync + 'static>(
&self,
file_id: u64,
position: u64,
value: T
)
pub fn replace_with_decoded<T: AnySendSync + 'static>(
&self,
file_id: u64,
position: u64,
value: T
)
Adds a new cached chunk for file_path at position.
Trait Implementations
sourceimpl Clone for ChunkCache
impl Clone for ChunkCache
sourcefn clone(&self) -> ChunkCache
fn clone(&self) -> ChunkCache
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl !RefUnwindSafe for ChunkCache
impl Send for ChunkCache
impl Sync for ChunkCache
impl Unpin for ChunkCache
impl !UnwindSafe for ChunkCache
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more