pub struct InvalidationCollector { /* private fields */ }Expand description
Mutable invalidation collector passed to transaction companion closures.
The collector is intentionally small and database-neutral. Repository code records the cache targets made stale by a write while keeping ownership of SQL/ORM execution inside the transaction closure.
Implementations§
Source§impl InvalidationCollector
impl InvalidationCollector
Sourcepub fn new(
namespace: impl Into<String>,
reason: impl Into<String>,
) -> InvalidationCollector
pub fn new( namespace: impl Into<String>, reason: impl Into<String>, ) -> InvalidationCollector
Create an empty collector for one cache namespace and operator-facing reason.
Sourcepub fn namespace(&self) -> &str
pub fn namespace(&self) -> &str
Return the namespace that should receive the collected invalidations.
Sourcepub fn intents(&self) -> &[InvalidationIntent]
pub fn intents(&self) -> &[InvalidationIntent]
Return collected intents in insertion order.
Sourcepub fn intent(
&mut self,
intent: InvalidationIntent,
) -> &mut InvalidationCollector
pub fn intent( &mut self, intent: InvalidationIntent, ) -> &mut InvalidationCollector
Add one already-normalized invalidation intent.
Sourcepub fn invalidate_key(
&mut self,
key: impl Into<String>,
) -> &mut InvalidationCollector
pub fn invalidate_key( &mut self, key: impl Into<String>, ) -> &mut InvalidationCollector
Add one physical cache-key invalidation.
Sourcepub fn invalidate_tag(
&mut self,
tag: impl Into<String>,
) -> &mut InvalidationCollector
pub fn invalidate_tag( &mut self, tag: impl Into<String>, ) -> &mut InvalidationCollector
Add one tag invalidation.
Sourcepub fn invalidate_entity(
&mut self,
entity: impl Into<String>,
key: impl Into<String>,
) -> &mut InvalidationCollector
pub fn invalidate_entity( &mut self, entity: impl Into<String>, key: impl Into<String>, ) -> &mut InvalidationCollector
Add one entity-tag invalidation.
Sourcepub fn invalidate_collection(
&mut self,
collection: impl Into<String>,
) -> &mut InvalidationCollector
pub fn invalidate_collection( &mut self, collection: impl Into<String>, ) -> &mut InvalidationCollector
Add one collection-tag invalidation.
Sourcepub fn flush(&mut self) -> &mut InvalidationCollector
pub fn flush(&mut self) -> &mut InvalidationCollector
Add a cache-wide flush invalidation.
Sourcepub fn cache_entity<E>(
&mut self,
id: <E as CacheEntity>::Id,
) -> &mut InvalidationCollectorwhere
E: CacheEntity,
pub fn cache_entity<E>(
&mut self,
id: <E as CacheEntity>::Id,
) -> &mut InvalidationCollectorwhere
E: CacheEntity,
Add both entity and collection invalidations for a cache entity id.
Sourcepub fn into_collected(self) -> CollectedInvalidations
pub fn into_collected(self) -> CollectedInvalidations
Finish collection and return an immutable invalidation payload.
Trait Implementations§
Source§impl Clone for InvalidationCollector
impl Clone for InvalidationCollector
Source§fn clone(&self) -> InvalidationCollector
fn clone(&self) -> InvalidationCollector
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InvalidationCollector
impl Debug for InvalidationCollector
Source§impl Default for InvalidationCollector
impl Default for InvalidationCollector
Source§fn default() -> InvalidationCollector
fn default() -> InvalidationCollector
impl Eq for InvalidationCollector
Source§impl PartialEq for InvalidationCollector
impl PartialEq for InvalidationCollector
Source§fn eq(&self, other: &InvalidationCollector) -> bool
fn eq(&self, other: &InvalidationCollector) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for InvalidationCollector
Auto Trait Implementations§
impl Freeze for InvalidationCollector
impl RefUnwindSafe for InvalidationCollector
impl Send for InvalidationCollector
impl Sync for InvalidationCollector
impl Unpin for InvalidationCollector
impl UnsafeUnpin for InvalidationCollector
impl UnwindSafe for InvalidationCollector
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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