pub struct DialCache { /* private fields */ }Expand description
A cache instance: request, process-local and remote layers behind explicit enablement.
Instances are cheap to clone and share one state.
Implementations§
Source§impl DialCache
impl DialCache
Sourcepub fn builder() -> DialCacheBuilder
pub fn builder() -> DialCacheBuilder
Start configuring an instance with the defaults documented on
DialCacheBuilder’s setters.
Sourcepub fn enable_guard(&self) -> ScopeGuard
pub fn enable_guard(&self) -> ScopeGuard
Sourcepub async fn enable<F, Fut, R>(&self, f: F) -> R
pub async fn enable<F, Fut, R>(&self, f: F) -> R
Open the outermost enabled scope for f. The scope closes when the
returned future completes, is dropped before completion, or unwinds;
retained clones then pass through.
Sourcepub async fn enable_in<F, Fut, R>(&self, parent: &Scope, f: F) -> R
pub async fn enable_in<F, Fut, R>(&self, parent: &Scope, f: F) -> R
Enable caching inside parent, reusing its live outer request memo.
When parent has no live outer scope, this opens a new one.
Sourcepub async fn disable_in<F, Fut, R>(&self, parent: &Scope, f: F) -> R
pub async fn disable_in<F, Fut, R>(&self, parent: &Scope, f: F) -> R
Disable caching inside parent while preserving its outer request memo
for nested re-enablement.
Sourcepub fn is_enabled(&self, scope: &Scope) -> bool
pub fn is_enabled(&self, scope: &Scope) -> bool
Whether calls made with scope on this instance use caching.
Sourcepub fn coalescing_state(&self) -> CoalescingState
pub fn coalescing_state(&self) -> CoalescingState
Process-scoped single-flight state of this instance.
Sourcepub async fn invalidate(
&self,
key_type: &str,
id: impl IntoKeyId,
future_buffer_ms: u64,
) -> Result<(), Error>
pub async fn invalidate( &self, key_type: &str, id: impl IntoKeyId, future_buffer_ms: u64, ) -> Result<(), Error>
Advance the invalidation watermark of every tracked variant of one
entity, in this instance’s namespace. Call it after the source
mutation commits. Requires a remote adapter; failures are returned.
IDs use the same IntoKeyId conversion as crate::KeySpec::new.
Sourcepub async fn invalidate_identity(
&self,
identity: Identity,
future_buffer_ms: u64,
) -> Result<(), Error>
pub async fn invalidate_identity( &self, identity: Identity, future_buffer_ms: u64, ) -> Result<(), Error>
Advance the watermark for the entity named by identity after its
source mutation commits. An empty namespace inherits this instance’s;
an explicit namespace is preserved, exactly as in get_or_load.
All use cases and argument variants share the entity’s watermark.
tracked is ignored: this operation always invalidates tracked remote
values. Local entries and already acquired snapshots retain their lifetimes.
Requires a remote adapter; mutation failures are returned to the caller.
Sourcepub async fn get_or_load<T, F, Fut>(
&self,
scope: &Scope,
operation: Operation<T>,
load: F,
) -> Result<Arc<T>, Error>
pub async fn get_or_load<T, F, Fut>( &self, scope: &Scope, operation: Operation<T>, load: F, ) -> Result<Arc<T>, Error>
Execute one inline cached call.
load is the source of truth; it may be invoked again later by
served-hit shadow validation, so it must be reusable. The returned
value is shared by reference: treat it as immutable.