pub struct MemoryTracker { /* private fields */ }Expand description
Tracks memory usage for a single keyspace.
All updates are explicit — callers must call add / remove on every
mutation. This avoids any hidden scanning cost.
Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn used_bytes(&self) -> usize
pub fn used_bytes(&self) -> usize
Returns the current estimated memory usage in bytes.
Sourcepub fn replace(&mut self, key: &str, old_value: &Value, new_value: &Value)
pub fn replace(&mut self, key: &str, old_value: &Value, new_value: &Value)
Adjusts tracking when a key’s value is overwritten.
Removes the old value’s contribution and adds the new one. Key count stays the same.
Sourcepub fn adjust(&mut self, old_entry_size: usize, new_entry_size: usize)
pub fn adjust(&mut self, old_entry_size: usize, new_entry_size: usize)
Adjusts used bytes for an in-place mutation (e.g. list push/pop) without changing the key count.
old_entry_size and new_entry_size are the full entry sizes
(as returned by entry_size) before and after the mutation.
Sourcepub fn remove_with_size(&mut self, size: usize)
pub fn remove_with_size(&mut self, size: usize)
Removes an entry with an explicit size, useful when the value has already been mutated and the original size was captured beforehand.
Trait Implementations§
Source§impl Debug for MemoryTracker
impl Debug for MemoryTracker
Auto Trait Implementations§
impl Freeze for MemoryTracker
impl RefUnwindSafe for MemoryTracker
impl Send for MemoryTracker
impl Sync for MemoryTracker
impl Unpin for MemoryTracker
impl UnwindSafe for MemoryTracker
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