pub struct SearchResultCache { /* private fields */ }Expand description
Search result cache with adaptive thresholds
Implementations§
Source§impl SearchResultCache
impl SearchResultCache
pub fn new(config: AdaptiveCacheConfig) -> Self
Sourcepub fn current_threshold(&self) -> f32
pub fn current_threshold(&self) -> f32
Get current similarity threshold
Sourcepub fn hash_query(query: &str) -> u64
pub fn hash_query(query: &str) -> u64
Hash a query string
Sourcepub fn get(
&self,
query: &str,
query_embedding: Option<&[f32]>,
filters: &CacheFilterParams,
) -> Option<Vec<SearchResult>>
pub fn get( &self, query: &str, query_embedding: Option<&[f32]>, filters: &CacheFilterParams, ) -> Option<Vec<SearchResult>>
Try to get cached results for a query
Sourcepub fn put(
&self,
query: &str,
query_embedding: Option<Vec<f32>>,
filters: CacheFilterParams,
results: Vec<SearchResult>,
)
pub fn put( &self, query: &str, query_embedding: Option<Vec<f32>>, filters: CacheFilterParams, results: Vec<SearchResult>, )
Store search results in cache
Sourcepub fn remove_expired(&self)
pub fn remove_expired(&self)
Remove expired entries
Sourcepub fn invalidate_for_workspace(&self, workspace: Option<&str>)
pub fn invalidate_for_workspace(&self, workspace: Option<&str>)
Invalidate cache entries for a specific workspace
Sourcepub fn invalidate_for_memory(&self, memory_id: i64)
pub fn invalidate_for_memory(&self, memory_id: i64)
Invalidate cache entries that might contain a specific memory
Sourcepub fn record_feedback(
&self,
query: &str,
filters: &CacheFilterParams,
positive: bool,
)
pub fn record_feedback( &self, query: &str, filters: &CacheFilterParams, positive: bool, )
Record feedback for a query (adjusts adaptive threshold)
Sourcepub fn stats(&self) -> CacheStatsResponse
pub fn stats(&self) -> CacheStatsResponse
Get cache statistics
Sourcepub fn start_expiration_worker(cache: Arc<Self>, interval_secs: u64)
pub fn start_expiration_worker(cache: Arc<Self>, interval_secs: u64)
Start background expiration worker (call from main thread)
Auto Trait Implementations§
impl !Freeze for SearchResultCache
impl !RefUnwindSafe for SearchResultCache
impl Send for SearchResultCache
impl Sync for SearchResultCache
impl Unpin for SearchResultCache
impl UnsafeUnpin for SearchResultCache
impl UnwindSafe for SearchResultCache
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 moreCreates a shared type from an unshared type.