pub struct PromptCache { /* private fields */ }
Expand description
Prompt caching system
Implementations§
Source§impl PromptCache
impl PromptCache
pub fn new() -> Self
pub fn with_config(config: PromptCacheConfig) -> Self
Sourcepub fn get(&mut self, prompt_hash: &str) -> Option<&CachedPrompt>
pub fn get(&mut self, prompt_hash: &str) -> Option<&CachedPrompt>
Get cached optimized prompt
Sourcepub fn put(&mut self, entry: CachedPrompt) -> Result<(), PromptCacheError>
pub fn put(&mut self, entry: CachedPrompt) -> Result<(), PromptCacheError>
Store optimized prompt in cache
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn clear(&mut self) -> Result<(), PromptCacheError>
pub fn clear(&mut self) -> Result<(), PromptCacheError>
Clear all cache entries
Sourcepub fn hash_prompt(prompt: &str) -> String
pub fn hash_prompt(prompt: &str) -> String
Generate hash for prompt
Sourcepub fn save_cache(&self) -> Result<(), PromptCacheError>
pub fn save_cache(&self) -> Result<(), PromptCacheError>
Save cache to disk
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PromptCache
impl RefUnwindSafe for PromptCache
impl Send for PromptCache
impl Sync for PromptCache
impl Unpin for PromptCache
impl UnwindSafe for PromptCache
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