pub struct SemanticCacheCore { /* private fields */ }Expand description
Pure cache bookkeeping (no embedder, no retriever — fully unit-testable).
Implementations§
Source§impl SemanticCacheCore
impl SemanticCacheCore
Sourcepub fn new(config: SemanticCacheConfig) -> Self
pub fn new(config: SemanticCacheConfig) -> Self
Creates a core with the given config.
Sourcepub fn lookup(
&self,
query: &str,
query_vector: Option<&[f32]>,
k: usize,
now: Instant,
) -> Option<(Vec<SearchResult>, CacheHitKind)>
pub fn lookup( &self, query: &str, query_vector: Option<&[f32]>, k: usize, now: Instant, ) -> Option<(Vec<SearchResult>, CacheHitKind)>
Looks up query (optionally with its embedding for semantic matching)
for result sets of size k. Returns the cached results and the hit kind.
query_vector should be the freshly embedded query; pass None to
restrict to lexical hits only.
Sourcepub fn insert(
&self,
query: &str,
query_vector: Vec<f32>,
k: usize,
results: Vec<SearchResult>,
now: Instant,
)
pub fn insert( &self, query: &str, query_vector: Vec<f32>, k: usize, results: Vec<SearchResult>, now: Instant, )
Inserts a result set for (query, k).
Sourcepub fn invalidate(&self)
pub fn invalidate(&self)
Clears all entries (corpus update invalidation).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SemanticCacheCore
impl RefUnwindSafe for SemanticCacheCore
impl Send for SemanticCacheCore
impl Sync for SemanticCacheCore
impl Unpin for SemanticCacheCore
impl UnsafeUnpin for SemanticCacheCore
impl UnwindSafe for SemanticCacheCore
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