pub struct CacheManager {
memory_cache: HashMap<String, CacheEntry>,
config: CacheConfig,
stats: CacheStats,
}Expand description
缓存管理器
Fields§
§memory_cache: HashMap<String, CacheEntry>内存缓存
config: CacheConfig缓存配置
stats: CacheStats缓存统计
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub async fn new(
translation_config: &TranslationConfig,
) -> TranslationResult<Self>
pub async fn new( translation_config: &TranslationConfig, ) -> TranslationResult<Self>
创建新的缓存管理器
Sourcepub fn cleanup_expired_entries(&mut self)
pub fn cleanup_expired_entries(&mut self)
清理过期项
Sourcefn evict_oldest_entries(&mut self, count: usize)
fn evict_oldest_entries(&mut self, count: usize)
移除最老的条目
Sourcefn generate_key(&self, text: &str) -> String
fn generate_key(&self, text: &str) -> String
生成缓存键
Sourcepub fn get_stats(&self) -> &CacheStats
pub fn get_stats(&self) -> &CacheStats
获取缓存统计
Sourceasync fn load_persistent_cache(&mut self) -> TranslationResult<()>
async fn load_persistent_cache(&mut self) -> TranslationResult<()>
加载持久化缓存
Sourcepub async fn save_persistent_cache(&self) -> TranslationResult<()>
pub async fn save_persistent_cache(&self) -> TranslationResult<()>
保存持久化缓存
Auto Trait Implementations§
impl Freeze for CacheManager
impl RefUnwindSafe for CacheManager
impl Send for CacheManager
impl Sync for CacheManager
impl Unpin for CacheManager
impl UnwindSafe for CacheManager
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