pub struct CacheStats { /* private fields */ }Expand description
Aggregate prompt-caching statistics collected across one agent session.
The counters are cumulative totals, not per-turn deltas. Hosts wanting
per-turn metrics should take snapshots via CacheStats::snapshot
and diff two snapshots; hosts wanting a single rolling rate can read
CacheStats::hit_rate directly.
Implementations§
Source§impl CacheStats
impl CacheStats
Sourcepub fn record(&mut self, usage: &Usage)
pub fn record(&mut self, usage: &Usage)
Records a single Usage observation.
Missing fields on usage are treated as zero so providers that
do not report cache metrics simply contribute nothing to the
cache numerator. The request counter increments on every call
regardless of field availability, so Self::requests is a
faithful count of observed usage payloads.
Sourcepub const fn prompt_tokens(&self) -> u64
pub const fn prompt_tokens(&self) -> u64
Returns cumulative prompt tokens (cached + fresh).
Sourcepub const fn cache_read_tokens(&self) -> u64
pub const fn cache_read_tokens(&self) -> u64
Returns cumulative tokens served from the KV cache.
Sourcepub const fn cache_write_tokens(&self) -> u64
pub const fn cache_write_tokens(&self) -> u64
Returns cumulative tokens freshly written to the KV cache.
Trait Implementations§
Source§impl Clone for CacheStats
impl Clone for CacheStats
impl Copy for CacheStats
Source§impl Debug for CacheStats
impl Debug for CacheStats
Source§impl Default for CacheStats
impl Default for CacheStats
impl Eq for CacheStats
Source§impl PartialEq for CacheStats
impl PartialEq for CacheStats
impl StructuralPartialEq for CacheStats
Auto Trait Implementations§
impl Forget for CacheStats
impl Freeze for CacheStats
impl Move for CacheStats
impl RefUnwindSafe for CacheStats
impl Send for CacheStats
impl Sync for CacheStats
impl Unpin for CacheStats
impl UnsafeUnpin for CacheStats
impl UnwindSafe for CacheStats
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
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
key and return true if they are equal.