pub struct DialCacheBuilder { /* private fields */ }Expand description
Configures a DialCache.
Implementations§
Source§impl DialCacheBuilder
impl DialCacheBuilder
Sourcepub fn namespace(self, namespace: impl Into<String>) -> Self
pub fn namespace(self, namespace: impl Into<String>) -> Self
Logical namespace used in keys, invalidation identity, cohorts and
labels. Defaults to "urn"; may not contain { or }.
Sourcepub fn remote(self, remote: impl Remote) -> Self
pub fn remote(self, remote: impl Remote) -> Self
The remote layer adapter. Without one, only request and local layers serve.
Sourcepub fn remote_arc(self, remote: Arc<dyn Remote>) -> Self
pub fn remote_arc(self, remote: Arc<dyn Remote>) -> Self
The remote layer adapter, shared.
Sourcepub fn observer(self, observer: impl Observer) -> Self
pub fn observer(self, observer: impl Observer) -> Self
Receives every public diagnostic; also the shadow outcome hook.
Sourcepub fn observer_arc(self, observer: Arc<dyn Observer>) -> Self
pub fn observer_arc(self, observer: Arc<dyn Observer>) -> Self
Receives every public diagnostic, shared.
Sourcepub fn logger(self, logger: impl Logger) -> Self
pub fn logger(self, logger: impl Logger) -> Self
Receives structured log events. Defaults to the log crate facade
under target dialcache.
Sourcepub fn logger_arc(self, logger: Arc<dyn Logger>) -> Self
pub fn logger_arc(self, logger: Arc<dyn Logger>) -> Self
Receives structured log events, shared.
Sourcepub fn policy_provider<F, Fut>(self, provider: F) -> Self
pub fn policy_provider<F, Fut>(self, provider: F) -> Self
Runtime policy overlay resolved once per enabled call. Ok(None)
inherits the operation policy; an error bypasses caching for that call.
Sourcepub fn local_capacity(self, capacity: usize) -> Self
pub fn local_capacity(self, capacity: usize) -> Self
Maximum process-local entries across every use case. Zero disables local storage while preserving coalescing. Defaults to 10,000.
Sourcepub fn local_store(self, store: Box<dyn LocalStore>) -> Self
pub fn local_store(self, store: Box<dyn LocalStore>) -> Self
Replace the default LRU store. Advanced: the store must preserve the documented LRU, expiry and promotion rules.
Sourcepub fn remote_read_timeout_ms(self, ms: u64) -> Self
pub fn remote_read_timeout_ms(self, ms: u64) -> Self
Instance default remote read budget. Defaults to 50 ms.
Sourcepub fn shadow_max_in_flight(self, jobs: usize) -> Self
pub fn shadow_max_in_flight(self, jobs: usize) -> Self
Concurrent shadow jobs per instance; excess work is dropped. Defaults to 1.
Sourcepub fn should_recover(
self,
predicate: impl Fn(&Error) -> bool + Send + Sync + 'static,
) -> Self
pub fn should_recover( self, predicate: impl Fn(&Error) -> bool + Send + Sync + 'static, ) -> Self
Instance default classifier deciding whether a source failure may use a retained stale value. Omission admits only the source deadline error.
Sourcepub fn compression(self, config: CompressionConfig) -> Self
pub fn compression(self, config: CompressionConfig) -> Self
Write-side compression policy. Enabled by default at a 4,096-byte threshold.
Sourcepub fn disable_compression(self) -> Self
pub fn disable_compression(self) -> Self
Store every payload uncompressed. Reads still accept compressed entries.
Sourcepub fn clock(self, clock: impl Clock) -> Self
pub fn clock(self, clock: impl Clock) -> Self
Replace the wall and elapsed clock. Defaults to
SystemClock.
Sourcepub fn clock_arc(self, clock: Arc<dyn Clock>) -> Self
pub fn clock_arc(self, clock: Arc<dyn Clock>) -> Self
Share a clock between instances (for example a controlled test clock).
Sourcepub fn runtime_arc(self, runtime: Arc<dyn Runtime>) -> Self
pub fn runtime_arc(self, runtime: Arc<dyn Runtime>) -> Self
Share a runtime between instances.
Sourcepub fn runtime(self, runtime: impl Runtime) -> Self
pub fn runtime(self, runtime: impl Runtime) -> Self
Replace the executor and timer source. Defaults to tokio.
Sourcepub fn build(self) -> Result<DialCache, ConfigError>
pub fn build(self) -> Result<DialCache, ConfigError>
Validate the configuration and create the instance. Rejects a
namespace containing { or }, a read budget outside
1..=2_147_483_647 ms, a zero shadow cap, an invalid compression
config, or no usable runtime: with the tokio feature, no tokio
runtime is current and none was supplied through runtime or
runtime_arc; without it, no runtime was supplied.