pub struct BoxedCacheInvalidator { /* private fields */ }Expand description
Built-in invalidator that drops keys directly from a
BoxedCache. Use when the host wires the same cache instance
into both CachePageLayer and the admin state. The key shape
mirrors what rustango::cache_page writes.
Implementations§
Source§impl BoxedCacheInvalidator
impl BoxedCacheInvalidator
Sourcepub fn new(cache: BoxedCache, key_prefix: impl Into<String>) -> Self
pub fn new(cache: BoxedCache, key_prefix: impl Into<String>) -> Self
Build a new invalidator targeting cache with the public
router’s key_prefix.
Sourcepub fn with_tenant_hosts(
self,
tenant_slug: impl Into<String>,
hosts: impl IntoIterator<Item = String>,
) -> Self
pub fn with_tenant_hosts( self, tenant_slug: impl Into<String>, hosts: impl IntoIterator<Item = String>, ) -> Self
Map a tenant slug to one or more Host header values. Both
acme.localhost and acme.localhost:8090 should be added
when the same site is reachable via both.
Sourcepub fn with_default_hosts(self, hosts: impl IntoIterator<Item = String>) -> Self
pub fn with_default_hosts(self, hosts: impl IntoIterator<Item = String>) -> Self
Fallback host list — used when a tenant slug isn’t in the per-tenant map. Set this in single-tenant deployments where every CMS URL lives under the same Host.
Sourcepub fn with_vary_values(
self,
pairs: impl IntoIterator<Item = (String, String)>,
) -> Self
pub fn with_vary_values( self, pairs: impl IntoIterator<Item = (String, String)>, ) -> Self
Mirror the public layer’s vary_on(...) declarations. The
invalidator will purge the cross-product of (vary-name,
vary-value) for each URL.
Trait Implementations§
Source§impl PageCacheInvalidator for BoxedCacheInvalidator
impl PageCacheInvalidator for BoxedCacheInvalidator
Source§fn invalidate_url<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_slug: &'life1 str,
url_path: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invalidate_url<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_slug: &'life1 str,
url_path: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Drop the cache entry for the public render of
url_path on
the given tenant. Hosts pass the unprefixed page URL —
the implementation appends the configured URL prefix +
host(s) before computing the cache key.Source§fn invalidate_subtree<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_slug: &'life1 str,
url_path: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invalidate_subtree<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_slug: &'life1 str,
url_path: &'life2 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Drop every cache entry whose URL starts with
url_path /
(the page itself + every descendant). Called after a slug
rename, a move, or a subtree delete.Source§fn invalidate_urls<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_slug: &'life1 str,
url_paths: &'life2 [String],
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invalidate_urls<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_slug: &'life1 str,
url_paths: &'life2 [String],
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Drop the cache entries for many page URLs at once. The
default loops over
Self::invalidate_url — preserving the
per-URL behavior — but backends with a bulk-purge API
(Cloudflare files, Azure CDN contentPaths) should override
this to issue a single request instead of N. The purge fan-out
in crate::task_queue::purge_urls calls this so a batch
backend collapses a multi-URL save into one round-trip.Auto Trait Implementations§
impl !RefUnwindSafe for BoxedCacheInvalidator
impl !UnwindSafe for BoxedCacheInvalidator
impl Freeze for BoxedCacheInvalidator
impl Send for BoxedCacheInvalidator
impl Sync for BoxedCacheInvalidator
impl Unpin for BoxedCacheInvalidator
impl UnsafeUnpin for BoxedCacheInvalidator
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 moreCreates a shared type from an unshared type.