pub struct SnapshotCache { /* private fields */ }Expand description
Per-session snapshot cache. Owned by the session struct; not thread-shared (one session = one user, one cache).
Implementations§
Source§impl SnapshotCache
impl SnapshotCache
Sourcepub fn new() -> SnapshotCache
pub fn new() -> SnapshotCache
New empty cache. Initialises to “no cached snapshot, last seen counter is 0”.
Sourcepub fn try_reuse(&self) -> Option<SnapshotId>
pub fn try_reuse(&self) -> Option<SnapshotId>
Try to reuse the cached snapshot. Returns Some(id)
when (a) we have a cached snapshot AND (b) the global
counter hasn’t advanced since we cached it. Returns
None otherwise — the caller must fetch a fresh one.
Sourcepub fn cache(&mut self, snapshot: SnapshotId)
pub fn cache(&mut self, snapshot: SnapshotId)
Stash a freshly-fetched snapshot. Records the current
global counter so a later try_reuse can validate it
hasn’t been invalidated by an intervening commit.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Force-invalidate the cache. Used when the session knows
it just performed a write — even if try_reuse would
otherwise return the cached snapshot, the write makes
it stale for self-visibility.
Trait Implementations§
Source§impl Debug for SnapshotCache
impl Debug for SnapshotCache
Source§impl Default for SnapshotCache
impl Default for SnapshotCache
Source§fn default() -> SnapshotCache
fn default() -> SnapshotCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SnapshotCache
impl RefUnwindSafe for SnapshotCache
impl Send for SnapshotCache
impl Sync for SnapshotCache
impl Unpin for SnapshotCache
impl UnsafeUnpin for SnapshotCache
impl UnwindSafe for SnapshotCache
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request