Skip to main content

DialCacheBuilder

Struct DialCacheBuilder 

Source
pub struct DialCacheBuilder { /* private fields */ }
Expand description

Configures a DialCache.

Implementations§

Source§

impl DialCacheBuilder

Source

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 }.

Source

pub fn remote(self, remote: impl Remote) -> Self

The remote layer adapter. Without one, only request and local layers serve.

Source

pub fn remote_arc(self, remote: Arc<dyn Remote>) -> Self

The remote layer adapter, shared.

Source

pub fn observer(self, observer: impl Observer) -> Self

Receives every public diagnostic; also the shadow outcome hook.

Source

pub fn observer_arc(self, observer: Arc<dyn Observer>) -> Self

Receives every public diagnostic, shared.

Source

pub fn logger(self, logger: impl Logger) -> Self

Receives structured log events. Defaults to the log crate facade under target dialcache.

Source

pub fn logger_arc(self, logger: Arc<dyn Logger>) -> Self

Receives structured log events, shared.

Source

pub fn policy_provider<F, Fut>(self, provider: F) -> Self
where F: Fn(Identity) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Option<RuntimePolicy>, BoxError>> + Send + 'static,

Runtime policy overlay resolved once per enabled call. Ok(None) inherits the operation policy; an error bypasses caching for that call.

Source

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.

Source

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.

Source

pub fn remote_read_timeout_ms(self, ms: u64) -> Self

Instance default remote read budget. Defaults to 50 ms.

Source

pub fn shadow_max_in_flight(self, jobs: usize) -> Self

Concurrent shadow jobs per instance; excess work is dropped. Defaults to 1.

Source

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.

Source

pub fn compression(self, config: CompressionConfig) -> Self

Write-side compression policy. Enabled by default at a 4,096-byte threshold.

Source

pub fn disable_compression(self) -> Self

Store every payload uncompressed. Reads still accept compressed entries.

Source

pub fn clock(self, clock: impl Clock) -> Self

Replace the wall and elapsed clock. Defaults to SystemClock.

Source

pub fn clock_arc(self, clock: Arc<dyn Clock>) -> Self

Share a clock between instances (for example a controlled test clock).

Source

pub fn runtime_arc(self, runtime: Arc<dyn Runtime>) -> Self

Share a runtime between instances.

Source

pub fn runtime(self, runtime: impl Runtime) -> Self

Replace the executor and timer source. Defaults to tokio.

Source

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.

Trait Implementations§

Source§

impl Debug for DialCacheBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.