pub struct SemanticCache<V: Clone> { /* private fields */ }Expand description
Semantic cache with fuzzy key matching
Implementations§
Source§impl<V: Clone> SemanticCache<V>
impl<V: Clone> SemanticCache<V>
Sourcepub fn new(capacity: usize, similarity_threshold: f32) -> Self
pub fn new(capacity: usize, similarity_threshold: f32) -> Self
Create a new semantic cache
§Arguments
capacity- Maximum number of entriessimilarity_threshold- Minimum similarity for cache hit (0.0 to 1.0)- 1.0 = exact match only
- 0.95 = very similar (recommended for most use cases)
- 0.9 = moderately similar
- 0.8 = loosely similar
Sourcepub fn contains(&self, query: &[f32]) -> bool
pub fn contains(&self, query: &[f32]) -> bool
Check if cache contains a similar query (without retrieving)
Sourcepub fn cleanup_expired(&mut self)
pub fn cleanup_expired(&mut self)
Remove expired entries
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Auto Trait Implementations§
impl<V> Freeze for SemanticCache<V>
impl<V> RefUnwindSafe for SemanticCache<V>where
V: RefUnwindSafe,
impl<V> Send for SemanticCache<V>where
V: Send,
impl<V> Sync for SemanticCache<V>where
V: Sync,
impl<V> Unpin for SemanticCache<V>where
V: Unpin,
impl<V> UnwindSafe for SemanticCache<V>where
V: UnwindSafe,
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> 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