pub struct EventInvalidationStrategy {
pub prefix: String,
pub default_ttl: Duration,
pub use_versioning: bool,
}Expand description
Event-based invalidation strategy
This strategy explicitly invalidates cache entries in response to specific events.
Fields§
§prefix: StringKey prefix to use
default_ttl: DurationDefault TTL for cache entries
use_versioning: boolWhether to use versioned keys
Implementations§
Source§impl EventInvalidationStrategy
impl EventInvalidationStrategy
Sourcepub fn new(prefix: &str, default_ttl: Duration, use_versioning: bool) -> Self
pub fn new(prefix: &str, default_ttl: Duration, use_versioning: bool) -> Self
Create a new event-based invalidation strategy
Sourcepub async fn versioned_key(
&self,
cache: &dyn CacheService,
entity_type: &str,
) -> CacheResult<String>
pub async fn versioned_key( &self, cache: &dyn CacheService, entity_type: &str, ) -> CacheResult<String>
Generate a versioned key if versioning is enabled
Sourcepub async fn generate_key_async(
&self,
cache: &dyn CacheService,
entity_type: &str,
entity_id: &str,
) -> CacheResult<String>
pub async fn generate_key_async( &self, cache: &dyn CacheService, entity_type: &str, entity_id: &str, ) -> CacheResult<String>
Generate a key with versioning support for async contexts
Trait Implementations§
Source§impl Clone for EventInvalidationStrategy
impl Clone for EventInvalidationStrategy
Source§fn clone(&self) -> EventInvalidationStrategy
fn clone(&self) -> EventInvalidationStrategy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EventInvalidationStrategy
impl Debug for EventInvalidationStrategy
Source§impl InvalidationStrategy for EventInvalidationStrategy
impl InvalidationStrategy for EventInvalidationStrategy
Source§fn generate_key(&self, entity_type: &str, entity_id: &str) -> String
fn generate_key(&self, entity_type: &str, entity_id: &str) -> String
Generate a cache key for the given entity
Source§fn invalidate<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
cache: &'life1 dyn CacheService,
entity_type: &'life2 str,
entity_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn invalidate<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
cache: &'life1 dyn CacheService,
entity_type: &'life2 str,
entity_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Invalidate a cached entity
Source§fn invalidate_type<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cache: &'life1 dyn CacheService,
entity_type: &'life2 str,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invalidate_type<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cache: &'life1 dyn CacheService,
entity_type: &'life2 str,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Invalidate all entities of a certain type
Auto Trait Implementations§
impl Freeze for EventInvalidationStrategy
impl RefUnwindSafe for EventInvalidationStrategy
impl Send for EventInvalidationStrategy
impl Sync for EventInvalidationStrategy
impl Unpin for EventInvalidationStrategy
impl UnsafeUnpin for EventInvalidationStrategy
impl UnwindSafe for EventInvalidationStrategy
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