pub struct CacheManager { /* private fields */ }Expand description
Manages translation caching using a SQLite database.
The cache stores translations keyed by source text, target language, model, endpoint, and prompt hash to avoid redundant API calls.
§Example
use tl_cli::cache::CacheManager;
use tl_cli::translation::TranslationRequest;
let cache = CacheManager::new().unwrap();
let request = TranslationRequest {
source_text: "Hello".to_string(),
target_language: "ja".to_string(),
model: "gpt-4".to_string(),
endpoint: "https://api.openai.com".to_string(),
};
// Check cache
if let Some(cached) = cache.get(&request).unwrap() {
println!("Cached: {}", cached);
}Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new cache manager.
Initializes the SQLite database at ~/.cache/tl/translations.db.
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