pub struct Cache {
pub max_capacity: CacheCapacity,
pub ttl: Duration,
pub cache_articles: bool,
pub adaptive_precheck: bool,
pub disk: Option<DiskCache>,
}Expand description
Cache configuration for article caching
Fields§
§max_capacity: CacheCapacityMaximum cache size in bytes (memory tier for hybrid cache)
Supports human-readable formats:
- "1gb" = 1 GB
- "500mb" = 500 MB
- "64mb" = 64 MB (default)
- 10000 = 10,000 bytes
ttl: DurationTime-to-live for cached articles
cache_articles: boolWhether to cache article bodies (default: true)
When false:
- Cache still tracks backend availability (smart routing, 430 retry)
- Article bodies are NOT stored (saves ~750KB per article)
- Useful for availability-only mode with limited memory
When true:
- Full caching mode (bodies + availability tracking)
- Can serve articles from cache without backend query
adaptive_precheck: boolEnable adaptive availability prechecking for STAT/HEAD commands (default: false)
When true:
- STAT/HEAD commands with message-ID check all backends simultaneously
- Returns optimistic response to client immediately (assumes article exists)
- Updates availability cache in background based on actual backend responses
- Improves future routing decisions by learning which backends have articles
- For HEAD with cache_articles=true, also caches the headers
When false:
- STAT/HEAD commands use normal routing (single backend check)
Trade-off: Uses more backend connections but builds accurate availability data
disk: Option<DiskCache>Disk cache configuration (requires hybrid-cache feature)
When enabled, articles evicted from memory are written to disk, creating a two-tier cache (memory → disk → backend).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cache
impl<'de> Deserialize<'de> for Cache
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Cache
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
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> Code for Twhere
T: Serialize + DeserializeOwned,
impl<T> Code for Twhere
T: Serialize + DeserializeOwned,
Source§fn encode(&self, writer: &mut impl Write) -> Result<(), Error>
fn encode(&self, writer: &mut impl Write) -> Result<(), Error>
Encode the object into a writer. Read more
Source§fn decode(reader: &mut impl Read) -> Result<T, Error>
fn decode(reader: &mut impl Read) -> Result<T, Error>
Decode the object from a reader. Read more
Source§fn estimated_size(&self) -> usize
fn estimated_size(&self) -> usize
Estimated serialized size of the object. Read more
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