pub struct WhatCache { /* private fields */ }Expand description
Multi-level cache for the What framework
Implementations§
Source§impl WhatCache
impl WhatCache
Sourcepub fn with_config(config: CacheConfig) -> Self
pub fn with_config(config: CacheConfig) -> Self
Create a cache with custom configuration
Sourcepub async fn get(&self, key: &CacheKey) -> Option<CachedValue>
pub async fn get(&self, key: &CacheKey) -> Option<CachedValue>
Get a cached page/content
Sourcepub async fn set(&self, key: &CacheKey, value: CachedValue)
pub async fn set(&self, key: &CacheKey, value: CachedValue)
Cache a page/content
Cache a page/content and associate it with tags for targeted invalidation. Tags are typically collection names (e.g., “posts”, “users”).
Sourcepub async fn set_with_ttl(
&self,
key: &CacheKey,
value: CachedValue,
_ttl: Duration,
)
pub async fn set_with_ttl( &self, key: &CacheKey, value: CachedValue, _ttl: Duration, )
Cache a page/content with custom TTL
Sourcepub async fn invalidate(&self, key: &CacheKey)
pub async fn invalidate(&self, key: &CacheKey)
Invalidate a specific cache entry
Sourcepub async fn invalidate_by_tag(&self, tag: &str)
pub async fn invalidate_by_tag(&self, tag: &str)
Invalidate all entries matching a tag. If no entries are tagged, falls back to full cache clear.
Sourcepub async fn invalidate_content_type(&self, content_type: &str)
pub async fn invalidate_content_type(&self, content_type: &str)
Invalidate all content cache entries for a specific content type / collection. Uses the tag index for targeted invalidation. If no entries are tagged, falls back to full cache clear for safety.
Sourcepub async fn invalidate_user(&self, user_id: &str)
pub async fn invalidate_user(&self, user_id: &str)
Invalidate all cache entries for a specific user. Uses prefix matching on cache keys.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WhatCache
impl !UnwindSafe for WhatCache
impl Freeze for WhatCache
impl Send for WhatCache
impl Sync for WhatCache
impl Unpin for WhatCache
impl UnsafeUnpin for WhatCache
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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