pub struct MemoryCache { /* private fields */ }Expand description
In-memory BatchCache: batches that could not be uploaded wait for the next attempt,
bounded by max_bytes and 512 batches (MAX_BATCHES, oldest evicted). The newest batch always
stays, even when it alone is larger than max_bytes. Lost with the process.
Implementations§
Trait Implementations§
Source§impl BatchCache for MemoryCache
impl BatchCache for MemoryCache
Source§fn push(&self, id: &str, body: &[u8]) -> Result<Vec<String>>
fn push(&self, id: &str, body: &[u8]) -> Result<Vec<String>>
Store one encoded batch under
id: once this returns Ok the batch is committed (for
FileCache, on disk). Returns the ids of older batches evicted to make room (the
exporter counts their events as dropped).Source§fn replace(&self, old: &str, new: &[(String, Vec<u8>)]) -> Result<Vec<String>>
fn replace(&self, old: &str, new: &[(String, Vec<u8>)]) -> Result<Vec<String>>
Replace the batch
old with new (a split): all of new is committed before old
goes, and nothing is evicted in between, so a crash can duplicate records but never lose
them. A missing old returns io::ErrorKind::NotFound without storing children;
an error does not promise that a concurrently evicted parent still exists. Returns the
ids evicted afterwards, excluding any parent already reported as evicted.Source§fn read(&self, id: &str) -> Result<Vec<u8>>
fn read(&self, id: &str) -> Result<Vec<u8>>
The body stored under
id: ErrorKind::NotFound when it is gone, another error when it
exists but cannot be read right now (e.g. a locked device’s file protection).Source§fn remove(&self, id: &str) -> Result<()>
fn remove(&self, id: &str) -> Result<()>
Delete one batch; a batch already gone is not an error.
Source§fn clear(&self) -> Result<()>
fn clear(&self) -> Result<()>
Discard everything (telemetry disabled: nothing may be replayed later);
Err when
something could not be deleted.Source§fn take_evicted(&self) -> Vec<String>
fn take_evicted(&self) -> Vec<String>
Ids evicted before the exporter could see them (over the bounds when the cache
was opened), handed over once so they are counted as lost.
Auto Trait Implementations§
impl !Freeze for MemoryCache
impl Forget for MemoryCache
impl Move for MemoryCache
impl RefUnwindSafe for MemoryCache
impl Send for MemoryCache
impl Sync for MemoryCache
impl Unpin for MemoryCache
impl UnsafeUnpin for MemoryCache
impl UnwindSafe for MemoryCache
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