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
impl EntryOptions
Sourcepub fn new(duration: Duration) -> Self
pub fn new(duration: Duration) -> Self
Creates options with the given logical duration and all other fields at their defaults.
Sourcepub fn with_duration(self, duration: Duration) -> Self
pub fn with_duration(self, duration: Duration) -> Self
Sets the logical duration (the freshness window).
Sourcepub fn with_memory_duration(self, duration: Duration) -> Self
pub fn with_memory_duration(self, duration: Duration) -> Self
Overrides the L1-only logical duration (defaults to duration).
Sourcepub fn with_distributed_duration(self, duration: Duration) -> Self
pub fn with_distributed_duration(self, duration: Duration) -> Self
Overrides the L2-only logical duration (defaults to duration).
Sourcepub fn with_eager_refresh(self, threshold: Option<EagerThreshold>) -> Self
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.
Sourcepub fn with_jitter_max(self, jitter_max: Duration) -> Self
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).
Sourcepub fn with_lock_timeout(self, timeout: Timeout) -> Self
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.
Sourcepub fn with_memory_lock_timeout(self, timeout: Timeout) -> Self
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.
Sourcepub fn with_distributed_lock_timeout(self, timeout: Timeout) -> Self
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.
Sourcepub fn with_fail_safe(
self,
enabled: bool,
max_duration: Option<Duration>,
throttle_duration: Option<Duration>,
) -> Self
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?).
Sourcepub fn with_factory_timeouts(
self,
soft: Timeout,
hard: Timeout,
allow_background_completion: bool,
) -> Self
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.
Sourcepub fn with_priority(self, priority: Priority) -> Self
pub fn with_priority(self, priority: Priority) -> Self
Sets the memory-eviction priority.
Sourcepub fn with_size(self, size: i64) -> Self
pub fn with_size(self, size: i64) -> Self
Sets the entry’s size weight (forwarded to the backend’s size policy).
Sourcepub fn with_allow_stale_on_read_only(self, allow: bool) -> Self
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.
Sourcepub fn with_skip_memory(self, skip_read: bool, skip_write: bool) -> Self
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.
Sourcepub fn with_skip_distributed(self, skip_read: bool, skip_write: bool) -> Self
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.
Sourcepub fn with_skip_distributed_read_when_stale(self, skip: bool) -> Self
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).
Sourcepub fn with_distributed_fail_safe_max_duration(self, max: Duration) -> Self
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.
Sourcepub fn with_rethrow_distributed_exceptions(self, rethrow: bool) -> Self
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).
Sourcepub fn with_rethrow_serialization_exceptions(self, rethrow: bool) -> Self
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).
Sourcepub fn with_allow_background_backplane_operations(self, allow: bool) -> Self
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).
Sourcepub fn with_distributed_timeouts(self, soft: Timeout, hard: Timeout) -> Self
pub fn with_distributed_timeouts(self, soft: Timeout, hard: Timeout) -> Self
Sets the L2 soft/hard timeouts.
Sourcepub fn with_allow_background_distributed_operations(self, allow: bool) -> Self
pub fn with_allow_background_distributed_operations(self, allow: bool) -> Self
Performs L2 writes in the background (fire-and-forget) instead of awaiting.
Sourcepub fn with_skip_backplane_notifications(self, skip: bool) -> Self
pub fn with_skip_backplane_notifications(self, skip: bool) -> Self
Skips publishing a backplane notification for this operation.
Sourcepub fn is_fail_safe_enabled(&self) -> bool
pub fn is_fail_safe_enabled(&self) -> bool
true if fail-safe is enabled.
Sourcepub fn fail_safe_throttle_duration(&self) -> Duration
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.
Sourcepub fn eager_refresh_threshold(&self) -> Option<EagerThreshold>
pub fn eager_refresh_threshold(&self) -> Option<EagerThreshold>
The eager-refresh threshold, if enabled.
Sourcepub fn lock_timeout(&self) -> Timeout
pub fn lock_timeout(&self) -> Timeout
The general lock timeout — the fallback for the memory- and distributed-specific lock timeouts.
Sourcepub fn memory_lock_timeout(&self) -> Timeout
pub fn memory_lock_timeout(&self) -> Timeout
The effective in-memory single-flight lock timeout (memory_lock_timeout,
or lock_timeout when unset).
Sourcepub fn distributed_lock_timeout(&self) -> Timeout
pub fn distributed_lock_timeout(&self) -> Timeout
The effective cross-node distributed lock timeout
(distributed_lock_timeout, or lock_timeout when unset).
Sourcepub fn allow_timed_out_factory_background_completion(&self) -> bool
pub fn allow_timed_out_factory_background_completion(&self) -> bool
true if a timed-out factory is allowed to finish in the background.
Sourcepub fn skip_memory_read(&self) -> bool
pub fn skip_memory_read(&self) -> bool
true if L1 reads should be skipped.
Sourcepub fn skip_memory_write(&self) -> bool
pub fn skip_memory_write(&self) -> bool
true if L1 writes should be skipped.
Sourcepub fn allow_stale_on_read_only(&self) -> bool
pub fn allow_stale_on_read_only(&self) -> bool
true if read-only methods may return a stale value.
Sourcepub fn skip_backplane_notifications(&self) -> bool
pub fn skip_backplane_notifications(&self) -> bool
true if backplane notifications are suppressed for this operation.
Sourcepub fn allow_background_backplane_operations(&self) -> bool
pub fn allow_background_backplane_operations(&self) -> bool
true if a backplane publish may run in the background.
Sourcepub fn skip_distributed_read(&self) -> bool
pub fn skip_distributed_read(&self) -> bool
true if L2 reads should be skipped.
Sourcepub fn skip_distributed_read_when_stale(&self) -> bool
pub fn skip_distributed_read_when_stale(&self) -> bool
true if L2 reads should be skipped when the L1 entry is stale.
Sourcepub fn skip_distributed_locker(&self) -> bool
pub fn skip_distributed_locker(&self) -> bool
true if the cross-node distributed lock should be skipped for this op.
Sourcepub fn with_skip_distributed_locker(self, skip: bool) -> Self
pub fn with_skip_distributed_locker(self, skip: bool) -> Self
Skips the cross-node distributed lock for this operation.
Sourcepub fn enable_auto_clone(&self) -> bool
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.
Sourcepub fn with_enable_auto_clone(self, enable: bool) -> Self
pub fn with_enable_auto_clone(self, enable: bool) -> Self
Enables auto-clone of L1 values on read (see enable_auto_clone).
Sourcepub fn distributed_soft_timeout(&self) -> Timeout
pub fn distributed_soft_timeout(&self) -> Timeout
The L2 soft timeout (awaited L2 op when a fallback exists).
Sourcepub fn distributed_hard_timeout(&self) -> Timeout
pub fn distributed_hard_timeout(&self) -> Timeout
The L2 hard timeout (always enforced on an awaited L2 op).
Sourcepub fn skip_distributed_write(&self) -> bool
pub fn skip_distributed_write(&self) -> bool
true if L2 writes should be skipped.
Sourcepub fn allow_background_distributed_operations(&self) -> bool
pub fn allow_background_distributed_operations(&self) -> bool
true if L2 writes may run in the background.
Sourcepub fn rethrow_distributed_exceptions(&self) -> bool
pub fn rethrow_distributed_exceptions(&self) -> bool
true if L2 backend exceptions should bubble to the caller.
Sourcepub fn rethrow_serialization_exceptions(&self) -> bool
pub fn rethrow_serialization_exceptions(&self) -> bool
true if (de)serialization errors should bubble to the caller (the
FusionCache default is true).
Sourcepub fn rethrow_backplane_exceptions(&self) -> bool
pub fn rethrow_backplane_exceptions(&self) -> bool
true if backplane exceptions should bubble to the caller.
Sourcepub fn resolved_memory_duration(&self) -> Duration
pub fn resolved_memory_duration(&self) -> Duration
The effective L1 logical duration (memory_duration or duration).
Sourcepub fn resolved_distributed_duration(&self) -> Duration
pub fn resolved_distributed_duration(&self) -> Duration
The effective L2 logical duration (distributed_duration or duration).
Sourcepub fn resolved_distributed_fail_safe_max_duration(&self) -> Duration
pub fn resolved_distributed_fail_safe_max_duration(&self) -> Duration
The effective L2 fail-safe max duration.
Sourcepub fn physical_ttl(&self) -> Duration
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.
Sourcepub fn distributed_physical_ttl(&self) -> Duration
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.
Sourcepub fn appropriate_factory_timeout(&self, has_fallback: bool) -> Timeout
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.
Sourcepub fn appropriate_distributed_timeout(&self, has_fallback: bool) -> Timeout
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).
Sourcepub fn logical_expiration(&self, created: Timestamp) -> Timestamp
pub fn logical_expiration(&self, created: Timestamp) -> Timestamp
Computes the logical-expiration timestamp for a fresh entry created at
created, applying jitter (if any).
Sourcepub fn eager_refresh_at(&self, created: Timestamp) -> Option<Timestamp>
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
impl Clone for EntryOptions
Source§fn clone(&self) -> EntryOptions
fn clone(&self) -> EntryOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more