Skip to main content

EntryOptions

Struct EntryOptions 

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

Options controlling how a single entry is cached.

Build a baseline once (often via Cache::entry_options, which clones the cache’s defaults) and tweak per call with the chainable with_* methods.

Implementations§

Source§

impl EntryOptions

Source

pub fn new(duration: Duration) -> Self

Creates options with the given logical duration and all other fields at their defaults.

Source

pub fn with_duration(self, duration: Duration) -> Self

Sets the logical duration (the freshness window).

Source

pub fn with_memory_duration(self, duration: Duration) -> Self

Overrides the L1-only logical duration (defaults to duration).

Source

pub fn with_distributed_duration(self, duration: Duration) -> Self

Overrides the L2-only logical duration (defaults to duration).

Source

pub fn with_eager_refresh(self, threshold: Option<EagerThreshold>) -> Self

Enables eager (proactive, background) refresh at the given threshold. A None threshold disables eager refresh.

Source

pub fn with_jitter_max(self, jitter_max: Duration) -> Self

Sets the maximum random jitter added to a fresh entry’s logical expiration (anti-stampede across nodes).

Source

pub fn with_lock_timeout(self, timeout: Timeout) -> Self

Sets the general maximum wait for the per-key single-flight lock — the fallback for the memory- and distributed-specific lock timeouts.

Source

pub fn with_memory_lock_timeout(self, timeout: Timeout) -> Self

Overrides the wait for the in-memory single-flight lock (defaults to with_lock_timeout). FusionCache MemoryLockTimeout.

Source

pub fn with_distributed_lock_timeout(self, timeout: Timeout) -> Self

Overrides the wait for the cross-node distributed lock (defaults to with_lock_timeout). FusionCache DistributedLockTimeout.

Source

pub fn with_fail_safe( self, enabled: bool, max_duration: Option<Duration>, throttle_duration: Option<Duration>, ) -> Self

Enables or disables fail-safe and (optionally) tunes its windows.

Mirrors FusionCache’s SetFailSafe(isEnabled, maxDuration?, throttleDuration?).

Source

pub fn with_factory_timeouts( self, soft: Timeout, hard: Timeout, allow_background_completion: bool, ) -> Self

Sets the factory soft/hard timeouts and whether a timed-out factory keeps running in the background to update the cache.

Source

pub fn with_priority(self, priority: Priority) -> Self

Sets the memory-eviction priority.

Source

pub fn with_size(self, size: i64) -> Self

Sets the entry’s size weight (forwarded to the backend’s size policy).

Source

pub fn with_allow_stale_on_read_only(self, allow: bool) -> Self

Allows read-only methods (try_get, get_or_default) to return a stale value.

Source

pub fn with_skip_memory(self, skip_read: bool, skip_write: bool) -> Self

Skips reading from / writing to the L1 memory cache for this operation.

Source

pub fn with_skip_distributed(self, skip_read: bool, skip_write: bool) -> Self

Skips reading from / writing to the L2 distributed cache for this operation.

Source

pub fn with_skip_distributed_read_when_stale(self, skip: bool) -> Self

When the L1 entry is stale, skip reading L2 (a multi-node freshness optimization).

Source

pub fn with_distributed_fail_safe_max_duration(self, max: Duration) -> Self

Overrides the L2-specific fail-safe max duration (defaults to the general fail_safe_max_duration). FusionCache DistributedCacheFailSafeMaxDuration.

Source

pub fn with_rethrow_distributed_exceptions(self, rethrow: bool) -> Self

Rethrows L2 transport errors to the caller instead of degrading to a miss (FusionCache ReThrowDistributedCacheExceptions, default false).

Source

pub fn with_rethrow_serialization_exceptions(self, rethrow: bool) -> Self

Rethrows (de)serialization errors on the L2 path to the caller (FusionCache ReThrowSerializationExceptions, default true).

Source

pub fn with_allow_background_backplane_operations(self, allow: bool) -> Self

Runs backplane publishes in the background (fire-and-forget) instead of awaiting them (FusionCache AllowBackgroundBackplaneOperations, default true).

Source

pub fn with_distributed_timeouts(self, soft: Timeout, hard: Timeout) -> Self

Sets the L2 soft/hard timeouts.

Source

pub fn with_allow_background_distributed_operations(self, allow: bool) -> Self

Performs L2 writes in the background (fire-and-forget) instead of awaiting.

Source

pub fn with_skip_backplane_notifications(self, skip: bool) -> Self

Skips publishing a backplane notification for this operation.

Source

pub fn duration(&self) -> Duration

The logical duration (freshness window).

Source

pub fn is_fail_safe_enabled(&self) -> bool

true if fail-safe is enabled.

Source

pub fn fail_safe_throttle_duration(&self) -> Duration

The fail-safe throttle window: after a fail-safe activation, how long the stale value is served before the factory is retried.

Source

pub fn eager_refresh_threshold(&self) -> Option<EagerThreshold>

The eager-refresh threshold, if enabled.

Source

pub fn lock_timeout(&self) -> Timeout

The general lock timeout — the fallback for the memory- and distributed-specific lock timeouts.

Source

pub fn memory_lock_timeout(&self) -> Timeout

The effective in-memory single-flight lock timeout (memory_lock_timeout, or lock_timeout when unset).

Source

pub fn distributed_lock_timeout(&self) -> Timeout

The effective cross-node distributed lock timeout (distributed_lock_timeout, or lock_timeout when unset).

Source

pub fn allow_timed_out_factory_background_completion(&self) -> bool

true if a timed-out factory is allowed to finish in the background.

Source

pub fn skip_memory_read(&self) -> bool

true if L1 reads should be skipped.

Source

pub fn skip_memory_write(&self) -> bool

true if L1 writes should be skipped.

Source

pub fn allow_stale_on_read_only(&self) -> bool

true if read-only methods may return a stale value.

Source

pub fn priority(&self) -> Priority

The memory-eviction priority.

Source

pub fn skip_backplane_notifications(&self) -> bool

true if backplane notifications are suppressed for this operation.

Source

pub fn allow_background_backplane_operations(&self) -> bool

true if a backplane publish may run in the background.

Source

pub fn skip_distributed_read(&self) -> bool

true if L2 reads should be skipped.

Source

pub fn skip_distributed_read_when_stale(&self) -> bool

true if L2 reads should be skipped when the L1 entry is stale.

Source

pub fn skip_distributed_locker(&self) -> bool

true if the cross-node distributed lock should be skipped for this op.

Source

pub fn with_skip_distributed_locker(self, skip: bool) -> Self

Skips the cross-node distributed lock for this operation.

Source

pub fn enable_auto_clone(&self) -> bool

true if L1 values should be (deep-)cloned out on read.

In Rust this is effectively always true: reads return an owned V (value_cloned), so a caller mutating the returned value never affects the cached copy. The flag exists for API parity and to opt into the same guarantee explicitly.

Source

pub fn with_enable_auto_clone(self, enable: bool) -> Self

Enables auto-clone of L1 values on read (see enable_auto_clone).

Source

pub fn distributed_soft_timeout(&self) -> Timeout

The L2 soft timeout (awaited L2 op when a fallback exists).

Source

pub fn distributed_hard_timeout(&self) -> Timeout

The L2 hard timeout (always enforced on an awaited L2 op).

Source

pub fn skip_distributed_write(&self) -> bool

true if L2 writes should be skipped.

Source

pub fn allow_background_distributed_operations(&self) -> bool

true if L2 writes may run in the background.

Source

pub fn rethrow_distributed_exceptions(&self) -> bool

true if L2 backend exceptions should bubble to the caller.

Source

pub fn rethrow_serialization_exceptions(&self) -> bool

true if (de)serialization errors should bubble to the caller (the FusionCache default is true).

Source

pub fn rethrow_backplane_exceptions(&self) -> bool

true if backplane exceptions should bubble to the caller.

Source

pub fn resolved_memory_duration(&self) -> Duration

The effective L1 logical duration (memory_duration or duration).

Source

pub fn resolved_distributed_duration(&self) -> Duration

The effective L2 logical duration (distributed_duration or duration).

Source

pub fn resolved_distributed_fail_safe_max_duration(&self) -> Duration

The effective L2 fail-safe max duration.

Source

pub fn physical_ttl(&self) -> Duration

The physical time-to-live handed to the L1 backend.

With fail-safe enabled this is max(duration, fail_safe_max_duration) — not the sum — so an entry physically survives long enough to be reused as a stale fallback. Without fail-safe it is just the logical duration.

Source

pub fn distributed_physical_ttl(&self) -> Duration

The physical time-to-live handed to the L2 backend — the L2 analogue of physical_ttl, using the distributed-specific duration and fail-safe-max overrides.

Source

pub fn appropriate_factory_timeout(&self, has_fallback: bool) -> Timeout

Selects the factory timeout to enforce for this call.

The soft timeout only applies when fail-safe is on and a fallback value exists; the hard timeout always applies and wins when it is shorter.

Source

pub fn appropriate_distributed_timeout(&self, has_fallback: bool) -> Timeout

Selects the L2 (distributed) timeout to enforce for an awaited L2 read.

Mirrors appropriate_factory_timeout: the distributed soft timeout only applies when fail-safe is on and a fallback value exists; the hard timeout always applies and wins when it is shorter (FusionCache GetAppropriateDistributedCacheTimeout).

Source

pub fn logical_expiration(&self, created: Timestamp) -> Timestamp

Computes the logical-expiration timestamp for a fresh entry created at created, applying jitter (if any).

Source

pub fn eager_refresh_at(&self, created: Timestamp) -> Option<Timestamp>

Computes the eager-refresh trigger timestamp for an entry created at created, or None if eager refresh is disabled.

Trait Implementations§

Source§

impl Clone for EntryOptions

Source§

fn clone(&self) -> EntryOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EntryOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for EntryOptions

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more