pub struct MemoryDatabase {
pub conversations: ConversationStore,
pub embeddings: EmbeddingStore,
pub local_files: LocalFilesStore,
pub all_files: AllFilesStore,
pub api_keys: ApiKeysStore,
pub users: UsersStore,
pub session_file_contexts: SessionFileContextsStore,
pub session_summaries: SessionSummariesStore,
/* private fields */
}Expand description
Main database manager that coordinates all stores
Fields§
§conversations: ConversationStore§embeddings: EmbeddingStore§local_files: LocalFilesStore§all_files: AllFilesStore§api_keys: ApiKeysStore§users: UsersStore§session_file_contexts: SessionFileContextsStore§session_summaries: SessionSummariesStoreImplementations§
Source§impl MemoryDatabase
impl MemoryDatabase
Sourcepub fn new_in_memory() -> Result<Self>
pub fn new_in_memory() -> Result<Self>
Create an in-memory database (useful for testing)
Sourcepub fn begin_transaction(&self) -> Result<Transaction<'_>>
pub fn begin_transaction(&self) -> Result<Transaction<'_>>
Begin a transaction for atomic operations
Sourcepub fn with_transaction<T, F>(&self, f: F) -> Result<T>
pub fn with_transaction<T, F>(&self, f: F) -> Result<T>
Execute operations in a transaction
Sourcepub fn get_stats(&self) -> Result<DatabaseStats>
pub fn get_stats(&self) -> Result<DatabaseStats>
Get database statistics
Sourcepub fn cleanup_old_data(&self, older_than_days: i32) -> Result<usize>
pub fn cleanup_old_data(&self, older_than_days: i32) -> Result<usize>
Cleanup old data (older than specified days)
Sourcepub async fn create_kv_snapshot(
&self,
session_id: &str,
entries: &[KVEntry],
) -> Result<i64>
pub async fn create_kv_snapshot( &self, session_id: &str, entries: &[KVEntry], ) -> Result<i64>
Create a KV snapshot
Sourcepub async fn get_recent_kv_snapshots(
&self,
session_id: &str,
limit: usize,
) -> Result<Vec<KvSnapshot>>
pub async fn get_recent_kv_snapshots( &self, session_id: &str, limit: usize, ) -> Result<Vec<KvSnapshot>>
Get recent KV snapshots for a session
Sourcepub async fn get_kv_snapshot_entries(
&self,
snapshot_id: i64,
) -> Result<Vec<KVEntry>>
pub async fn get_kv_snapshot_entries( &self, snapshot_id: i64, ) -> Result<Vec<KVEntry>>
Get KV snapshot entries
Sourcepub async fn search_messages_by_keywords(
&self,
session_id: &str,
keywords: &[String],
limit: usize,
) -> Result<Vec<StoredMessage>>
pub async fn search_messages_by_keywords( &self, session_id: &str, keywords: &[String], limit: usize, ) -> Result<Vec<StoredMessage>>
Search messages by keywords (for ConversationStore)
Sourcepub async fn update_kv_cache_metadata(
&self,
session_id: &str,
state: &SessionCacheState,
) -> Result<()>
pub async fn update_kv_cache_metadata( &self, session_id: &str, state: &SessionCacheState, ) -> Result<()>
Update KV cache metadata
Sourcepub async fn cleanup_session_snapshots(&self, session_id: &str) -> Result<()>
pub async fn cleanup_session_snapshots(&self, session_id: &str) -> Result<()>
Cleanup session snapshots
Sourcepub async fn prune_old_kv_snapshots(&self, keep_max: usize) -> Result<usize>
pub async fn prune_old_kv_snapshots(&self, keep_max: usize) -> Result<usize>
Prune old KV snapshots
Sourcepub fn optimize(&self) -> Result<()>
pub fn optimize(&self) -> Result<()>
Run SQLite maintenance: update query planner statistics and truncate the WAL file.
PRAGMA optimize lets SQLite decide when to run ANALYZE — safe to call at any time.
PRAGMA wal_checkpoint(TRUNCATE) flushes the WAL to the main DB file and resets
the WAL to zero bytes, reclaiming disk space after heavy write sessions.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MemoryDatabase
impl !RefUnwindSafe for MemoryDatabase
impl Send for MemoryDatabase
impl Sync for MemoryDatabase
impl Unpin for MemoryDatabase
impl UnsafeUnpin for MemoryDatabase
impl !UnwindSafe for MemoryDatabase
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more