pub struct EmbeddingCache { /* private fields */ }Expand description
LRU cache for embedding vectors, keyed by hash of (model_name + text).
Implementations§
Source§impl EmbeddingCache
impl EmbeddingCache
Sourcepub fn new(max_size: usize) -> Self
pub fn new(max_size: usize) -> Self
Create a new cache with the given maximum number of entries.
Sourcepub fn default_size() -> Self
pub fn default_size() -> Self
Create a cache with the default size of 10,000 entries.
Sourcepub fn get(&mut self, text: &str, model: &str) -> Option<&[f32]>
pub fn get(&mut self, text: &str, model: &str) -> Option<&[f32]>
Look up a cached embedding. Returns None on cache miss.
Sourcepub fn put(&mut self, text: &str, model: &str, embedding: Vec<f32>)
pub fn put(&mut self, text: &str, model: &str, embedding: Vec<f32>)
Insert an embedding into the cache. Evicts the LRU entry if full.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics.
Auto Trait Implementations§
impl Freeze for EmbeddingCache
impl RefUnwindSafe for EmbeddingCache
impl Send for EmbeddingCache
impl Sync for EmbeddingCache
impl Unpin for EmbeddingCache
impl UnsafeUnpin for EmbeddingCache
impl UnwindSafe for EmbeddingCache
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