pub struct CacheInvalidationMiddleware { /* private fields */ }
Expand description
Cache invalidation middleware
Implementations§
Source§impl CacheInvalidationMiddleware
impl CacheInvalidationMiddleware
Sourcepub fn new(config: InvalidationConfig) -> Self
pub fn new(config: InvalidationConfig) -> Self
Create a new cache invalidation middleware
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new middleware with default configuration
Sourcepub fn register_handler(
&self,
handler: Box<dyn CacheInvalidationHandler + Send + Sync>,
)
pub fn register_handler( &self, handler: Box<dyn CacheInvalidationHandler + Send + Sync>, )
Register a cache invalidation handler
Sourcepub fn add_rule(&self, rule: InvalidationRule)
pub fn add_rule(&self, rule: InvalidationRule)
Add an invalidation rule
Sourcepub async fn process_event(&self, event: InvalidationEvent) -> Result<()>
pub async fn process_event(&self, event: InvalidationEvent) -> Result<()>
Process an invalidation event
§Errors
This function will return an error if the event processing fails
Sourcepub async fn manual_invalidate(
&self,
entity_type: &str,
entity_id: Option<Uuid>,
cache_types: Option<Vec<String>>,
) -> Result<()>
pub async fn manual_invalidate( &self, entity_type: &str, entity_id: Option<Uuid>, cache_types: Option<Vec<String>>, ) -> Result<()>
Manually invalidate caches
§Errors
This function will return an error if the manual invalidation fails
Sourcepub fn get_stats(&self) -> InvalidationStats
pub fn get_stats(&self) -> InvalidationStats
Get invalidation statistics
Sourcepub fn get_recent_events(&self, limit: usize) -> Vec<InvalidationEvent>
pub fn get_recent_events(&self, limit: usize) -> Vec<InvalidationEvent>
Get recent invalidation events
Sourcepub fn get_events_by_entity_type(
&self,
entity_type: &str,
) -> Vec<InvalidationEvent>
pub fn get_events_by_entity_type( &self, entity_type: &str, ) -> Vec<InvalidationEvent>
Get events by entity type
Auto Trait Implementations§
impl Freeze for CacheInvalidationMiddleware
impl !RefUnwindSafe for CacheInvalidationMiddleware
impl Send for CacheInvalidationMiddleware
impl Sync for CacheInvalidationMiddleware
impl Unpin for CacheInvalidationMiddleware
impl !UnwindSafe for CacheInvalidationMiddleware
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 more