pub struct SqliteCache { /* private fields */ }Expand description
SQLite-backed implementation of the LlmCache trait.
Stores serialized ChatResponse values in a SQLite table with optional
TTL expiration. Uses tokio::task::spawn_blocking to avoid blocking the
async runtime during SQLite operations.
Implementations§
Source§impl SqliteCache
impl SqliteCache
Sourcepub fn new(config: SqliteCacheConfig) -> Result<Self, SynapticError>
pub fn new(config: SqliteCacheConfig) -> Result<Self, SynapticError>
Create a new SqliteCache from the given configuration.
This opens (or creates) the SQLite database and initializes the cache table if it does not already exist.
Trait Implementations§
Source§impl LlmCache for SqliteCache
impl LlmCache for SqliteCache
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ChatResponse>, SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ChatResponse>, SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Look up a cached response by cache key.
Source§fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
response: &'life2 ChatResponse,
) -> Pin<Box<dyn Future<Output = Result<(), SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
response: &'life2 ChatResponse,
) -> Pin<Box<dyn Future<Output = Result<(), SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Store a response in the cache.
Auto Trait Implementations§
impl Freeze for SqliteCache
impl RefUnwindSafe for SqliteCache
impl Send for SqliteCache
impl Sync for SqliteCache
impl Unpin for SqliteCache
impl UnsafeUnpin for SqliteCache
impl UnwindSafe for SqliteCache
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