pub struct EmbeddingCache { /* private fields */ }Expand description
Content-addressable embedding cache with TTL and LRU eviction.
Implementations§
Source§impl EmbeddingCache
impl EmbeddingCache
Sourcepub fn new(ttl_secs: u64, max_entries: usize) -> Self
pub fn new(ttl_secs: u64, max_entries: usize) -> Self
Create a new cache with TTL and capacity.
§Arguments
ttl_secs- Time-to-live for cached entries in secondsmax_entries- Maximum number of entries to cache
Sourcepub fn content_hash(content: &str) -> u64
pub fn content_hash(content: &str) -> u64
Hash content to cache key.
Sourcepub fn get(&self, content: &str) -> Option<Vec<f32>>
pub fn get(&self, content: &str) -> Option<Vec<f32>>
Get cached embedding if exists and not expired.
Sourcepub fn evict_expired(&self) -> usize
pub fn evict_expired(&self) -> usize
Evict expired entries.
Returns the number of entries evicted.
Sourcepub fn evict_lru(&self, target_size: usize) -> usize
pub fn evict_lru(&self, target_size: usize) -> usize
Evict least recently used entries to free space.
Returns the number of entries evicted.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
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