pub struct RecordCache { /* private fields */ }Expand description
Thread-safe in-memory cache of ingested records keyed by record id.
Implementations§
Source§impl RecordCache
impl RecordCache
Sourcepub fn new(max_records: usize) -> Self
pub fn new(max_records: usize) -> Self
Create a cache capped to at most max_records live records.
Sourcepub fn ingest<I>(&self, records: I)where
I: IntoIterator<Item = DataRecord>,
pub fn ingest<I>(&self, records: I)where
I: IntoIterator<Item = DataRecord>,
Ingest a batch of records, replacing existing entries by id.
Sourcepub fn ingest_with_version<I>(&self, records: I, version: u64)where
I: IntoIterator<Item = DataRecord>,
pub fn ingest_with_version<I>(&self, records: I, version: u64)where
I: IntoIterator<Item = DataRecord>,
Ingest a batch of records with an explicit version number from the global counter.
Sourcepub fn snapshot(&self) -> Vec<Arc<DataRecord>>
pub fn snapshot(&self) -> Vec<Arc<DataRecord>>
Return a snapshot of current cached records as Arc references (cheap clone).
Sourcepub fn ingest_count(&self) -> u64
pub fn ingest_count(&self) -> u64
Return the number of completed ingest operations.
Sourcepub fn wait_for_ingest(&self, last_seen: u64, timeout: Duration) -> u64
pub fn wait_for_ingest(&self, last_seen: u64, timeout: Duration) -> u64
Wait until ingest count exceeds last_seen, or until timeout elapses.
Sourcepub fn wait_for_ingest_blocking(&self, last_seen: u64) -> u64
pub fn wait_for_ingest_blocking(&self, last_seen: u64) -> u64
Wait indefinitely until ingest count exceeds last_seen.
Sourcepub fn sync_delta(
&self,
last_version: u64,
) -> (u64, Vec<Arc<DataRecord>>, Vec<RecordId>)
pub fn sync_delta( &self, last_version: u64, ) -> (u64, Vec<Arc<DataRecord>>, Vec<RecordId>)
Return a delta of records added since last_version and record IDs evicted since last_version.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RecordCache
impl RefUnwindSafe for RecordCache
impl Send for RecordCache
impl Sync for RecordCache
impl Unpin for RecordCache
impl UnsafeUnpin for RecordCache
impl UnwindSafe for RecordCache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more