pub enum CacheTtl {
Minute,
Short,
Medium,
Hour,
Day,
Week,
Custom(u64),
}Expand description
Standard cache TTL values that encourage batch grouping.
Using standard TTLs means items naturally batch together for efficient pipelined writes. Custom durations are supported but should be used sparingly.
§Batching Behavior
Items with the same CacheTtl variant are batched together:
- 1000 items with
CacheTtl::Short→ 1 Redis pipeline - 500 items with
CacheTtl::Short+ 500 withCacheTtl::Hour→ 2 pipelines
§Example
use sync_engine::{SubmitOptions, CacheTtl};
// Prefer standard TTLs for batching efficiency
let opts = SubmitOptions::cache(CacheTtl::Hour);
// Custom TTL when you really need a specific duration
let opts = SubmitOptions::cache(CacheTtl::custom_secs(90));Variants§
Minute
1 minute - very short-lived cache
Short
5 minutes - short cache
Medium
15 minutes - medium cache
Hour
1 hour - standard cache (most common)
Day
24 hours - long cache
Week
7 days - very long cache
Custom(u64)
Custom duration in seconds (use sparingly to preserve batching)
Implementations§
Source§impl CacheTtl
impl CacheTtl
Sourcepub fn custom_secs(secs: u64) -> Self
pub fn custom_secs(secs: u64) -> Self
Create a custom TTL from seconds.
Prefer standard TTLs (Minute, Hour, etc.) for better batching.
Custom TTLs create separate batches, reducing pipeline efficiency.
Sourcepub fn to_duration(self) -> Duration
pub fn to_duration(self) -> Duration
Convert to Duration.
Trait Implementations§
impl Copy for CacheTtl
impl Eq for CacheTtl
impl StructuralPartialEq for CacheTtl
Auto Trait Implementations§
impl Freeze for CacheTtl
impl RefUnwindSafe for CacheTtl
impl Send for CacheTtl
impl Sync for CacheTtl
impl Unpin for CacheTtl
impl UnwindSafe for CacheTtl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more