pub struct SpeculativeCache { /* private fields */ }Implementations§
Source§impl SpeculativeCache
impl SpeculativeCache
pub fn new( max_size: usize, keyword_threshold: f32, embedding_threshold: f32, ) -> Self
pub fn pre_assemble( &mut self, predictions: Vec<String>, builder: impl Fn(&str) -> Option<(String, Vec<MemoryId>, Option<Vec<f32>>)>, )
Sourcepub fn try_hit(
&mut self,
query: &str,
query_embedding: Option<&[f32]>,
) -> Option<CacheEntry>
pub fn try_hit( &mut self, query: &str, query_embedding: Option<&[f32]>, ) -> Option<CacheEntry>
Try to find a cached context for this query. Uses cosine similarity on embeddings when available, falls back to keyword overlap only when no embeddings exist.
pub fn evict_stale(&mut self, max_age_us: u64, now: Timestamp)
pub fn stats(&self) -> CacheStats
Sourcepub fn entries(&self) -> &[CacheEntry]
pub fn entries(&self) -> &[CacheEntry]
The current cache entries (predicted topic, pre-assembled context, source memories, hit count, age), for introspection and display.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpeculativeCache
impl RefUnwindSafe for SpeculativeCache
impl Send for SpeculativeCache
impl Sync for SpeculativeCache
impl Unpin for SpeculativeCache
impl UnsafeUnpin for SpeculativeCache
impl UnwindSafe for SpeculativeCache
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