Skip to main content

synaptic_cache/
lib.rs

1mod cached_model;
2mod in_memory;
3mod semantic;
4
5pub use cached_model::CachedChatModel;
6pub use in_memory::InMemoryCache;
7pub use semantic::SemanticCache;
8
9use async_trait::async_trait;
10use synaptic_core::{ChatResponse, SynapseError};
11
12/// Trait for caching LLM responses.
13#[async_trait]
14pub trait LlmCache: Send + Sync {
15    /// Look up a cached response by cache key.
16    async fn get(&self, key: &str) -> Result<Option<ChatResponse>, SynapseError>;
17    /// Store a response in the cache.
18    async fn put(&self, key: &str, response: &ChatResponse) -> Result<(), SynapseError>;
19    /// Clear all entries from the cache.
20    async fn clear(&self) -> Result<(), SynapseError>;
21}