pub struct CacheConfig {
pub default_ttl: Duration,
pub ttl_jitter_percent: u8,
pub null_ttl: Duration,
pub single_flight: bool,
pub fail_open: bool,
}Expand description
缓存行为配置。
Fields§
§default_ttl: Duration默认 TTL。
ttl_jitter_percent: u8TTL 随机抖动百分比(0-100),用于分散过期时间、避免缓存雪崩。
null_ttl: Duration空值缓存 TTL。
single_flight: bool是否启用 single-flight(同一 key 并发 miss 只回源一次)。
fail_open: boolRedis 故障时是否按 cache miss 处理(仅适用于纯缓存场景)。
安全敏感路径必须保持 false(fail-closed)。
Trait Implementations§
Source§impl Clone for CacheConfig
impl Clone for CacheConfig
Source§impl Debug for CacheConfig
impl Debug for CacheConfig
Auto Trait Implementations§
impl Forget for CacheConfig
impl Freeze for CacheConfig
impl Move for CacheConfig
impl RefUnwindSafe for CacheConfig
impl Send for CacheConfig
impl Sync for CacheConfig
impl Unpin for CacheConfig
impl UnsafeUnpin for CacheConfig
impl UnwindSafe for CacheConfig
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<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