Skip to main content

synaptic_sqlite/
lib.rs

1//! SQLite integration for the Synaptic framework.
2//!
3//! This crate provides:
4//! - [`SqliteCache`]: A SQLite-backed implementation of the [`LlmCache`](synaptic_core::LlmCache)
5//!   trait for caching LLM responses with optional TTL expiration.
6//! - [`SqliteCheckpointer`]: A SQLite-backed implementation of the
7//!   [`Checkpointer`](synaptic_graph::Checkpointer) trait for persisting graph
8//!   state between executions.
9//!
10//! # Quick start
11//!
12//! ```rust,no_run
13//! use synaptic_sqlite::{SqliteCache, SqliteCacheConfig};
14//!
15//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
16//! // In-memory cache (great for testing)
17//! let cache = SqliteCache::new(SqliteCacheConfig::in_memory())?;
18//!
19//! // File-based cache with 1-hour TTL
20//! let config = SqliteCacheConfig::new("/tmp/llm_cache.db").with_ttl(3600);
21//! let cache = SqliteCache::new(config)?;
22//! # Ok(())
23//! # }
24//! ```
25
26mod cache;
27pub mod checkpointer;
28
29pub use cache::{SqliteCache, SqliteCacheConfig};
30pub use checkpointer::SqliteCheckpointer;
31
32// Re-export core traits for convenience.
33pub use synaptic_core::{ChatResponse, LlmCache};
34pub use synaptic_graph::Checkpointer;