pub struct CacheShareConfig {
pub alarm_threshold: Option<f64>,
pub window_secs: Option<u64>,
pub min_prompt_tokens: Option<u64>,
pub open_model_providers: Vec<String>,
pub open_model_patterns: Vec<String>,
pub open_model_policy: Option<String>,
}Expand description
[proxy.cache_share] — guards the provider prompt-cache discount.
Without prompt caching a long agent session bills every prompt token at
the full input rate; with it most prompt tokens bill at the cache-read
rate. The proxy keeps a rolling window per provider+model and raises an
alarm when the cache-read share of the prompt tokens drops below
alarm_threshold.
Open-weight models (Llama, Qwen, DeepSeek, …) are served by many hosts,
and not all of them give a reliable cache discount. A provider not in
open_model_providers is flagged (open_model_policy = "flag", the
default) or refused before the request leaves ("refuse"). Local
endpoints are exempt: nothing is bought there.
Fields§
§alarm_threshold: Option<f64>Minimum cache-read share (0–1) of the prompt tokens; default 0.90.
window_secs: Option<u64>Rolling window in seconds; default 3600, capped at 7 days.
min_prompt_tokens: Option<u64>Prompt tokens a window needs before the alarm may fire, so the cold first turn of a session (all cache writes) does not alarm; default 200 000.
open_model_providers: Vec<String>Provider ids (registry id or built-in label, case-insensitive) with a reliable cache discount, allowed to serve open models.
open_model_patterns: Vec<String>Extra model-name fragments (case-insensitive) counted as open models, added to the built-in list.
open_model_policy: Option<String>"flag" (default) or "refuse" for an open model on a provider
outside open_model_providers.
Implementations§
Sourcepub fn effective_threshold(&self) -> f64
pub fn effective_threshold(&self) -> f64
Configured threshold clamped to 0–1, or the 0.90 default.
Sourcepub fn effective_window_secs(&self) -> u64
pub fn effective_window_secs(&self) -> u64
Configured window clamped to 60 s – 7 days, or one hour.
Sourcepub fn effective_min_prompt_tokens(&self) -> u64
pub fn effective_min_prompt_tokens(&self) -> u64
Configured minimum prompt tokens, or the default.
Sourcepub fn refuses_unlisted_open_models(&self) -> bool
pub fn refuses_unlisted_open_models(&self) -> bool
True when an unlisted provider must refuse an open model; any value
other than "refuse" flags only.
Trait Implementations§
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>,
Auto Trait Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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