pub struct EmbeddingCache { /* private fields */ }Expand description
嵌入缓存
使用 LRU 策略管理缓存条目。
Implementations§
Source§impl EmbeddingCache
impl EmbeddingCache
Sourcepub fn default_cache() -> Self
pub fn default_cache() -> Self
使用默认配置创建缓存
Sourcepub async fn get(
&self,
provider: &str,
model: &str,
text: &str,
) -> Option<Vec<f32>>
pub async fn get( &self, provider: &str, model: &str, text: &str, ) -> Option<Vec<f32>>
获取缓存的嵌入向量
Sourcepub async fn put(
&self,
provider: &str,
model: &str,
text: &str,
embedding: Vec<f32>,
)
pub async fn put( &self, provider: &str, model: &str, text: &str, embedding: Vec<f32>, )
存储嵌入向量到缓存
Sourcepub async fn get_batch(
&self,
provider: &str,
model: &str,
texts: &[String],
) -> Vec<Option<Vec<f32>>>
pub async fn get_batch( &self, provider: &str, model: &str, texts: &[String], ) -> Vec<Option<Vec<f32>>>
批量获取缓存的嵌入向量
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
获取缓存统计信息
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EmbeddingCache
impl !RefUnwindSafe for EmbeddingCache
impl !UnwindSafe for EmbeddingCache
impl Send for EmbeddingCache
impl Sync for EmbeddingCache
impl Unpin for EmbeddingCache
impl UnsafeUnpin 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