pub struct MetadataCache { /* private fields */ }Expand description
SQLite-based metadata cache (thread-safe)
Implementations§
Source§impl MetadataCache
impl MetadataCache
Sourcepub fn get(
&self,
path: &Path,
current_mtime: SystemTime,
) -> Result<Option<SessionMetadata>>
pub fn get( &self, path: &Path, current_mtime: SystemTime, ) -> Result<Option<SessionMetadata>>
Get cached metadata if fresh, otherwise None
Sourcepub fn put(
&self,
path: &Path,
meta: &SessionMetadata,
mtime: SystemTime,
) -> Result<()>
pub fn put( &self, path: &Path, meta: &SessionMetadata, mtime: SystemTime, ) -> Result<()>
Store metadata in cache
Sourcepub fn invalidate(&self, path: &Path) -> Result<()>
pub fn invalidate(&self, path: &Path) -> Result<()>
Invalidate cache entry for a path
Sourcepub fn get_project_paths(&self, project: &str) -> Result<Vec<PathBuf>>
pub fn get_project_paths(&self, project: &str) -> Result<Vec<PathBuf>>
Get all cached paths for a project
Sourcepub fn stats(&self) -> Result<CacheStats>
pub fn stats(&self) -> Result<CacheStats>
Get cache statistics
Sourcepub fn get_aggregate_stats(&self) -> Result<AggregateStats>
pub fn get_aggregate_stats(&self) -> Result<AggregateStats>
Get aggregate session stats from O(1) table (total sessions + messages)
Sourcepub fn search_sessions(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SearchResult>>
pub fn search_sessions( &self, query: &str, limit: usize, ) -> Result<Vec<SearchResult>>
Search sessions using FTS5 full-text search.
Returns up to limit results ranked by relevance (BM25).
Returns empty vec (not error) if FTS5 index doesn’t exist yet (graceful degradation).
Sourcepub fn rebuild_fts_index(&self) -> Result<usize>
pub fn rebuild_fts_index(&self) -> Result<usize>
Rebuild FTS5 index from existing session_metadata rows.
Called once after cache version bump to populate FTS5 for existing sessions.
Sourcepub fn get_activity(
&self,
path: &Path,
current_mtime: SystemTime,
) -> Result<Option<ActivitySummary>>
pub fn get_activity( &self, path: &Path, current_mtime: SystemTime, ) -> Result<Option<ActivitySummary>>
Get cached ActivitySummary if the session file mtime matches.
Returns None on cache miss or mtime mismatch (session was modified).
Sourcepub fn put_activity(
&self,
path: &Path,
session_id: &str,
summary: &ActivitySummary,
mtime: SystemTime,
) -> Result<()>
pub fn put_activity( &self, path: &Path, session_id: &str, summary: &ActivitySummary, mtime: SystemTime, ) -> Result<()>
Store an ActivitySummary in cache, keyed by session file path + mtime.
Also populates the activity_alerts table for cross-session alert queries.
Sourcepub fn invalidate_activity(&self, path: &Path) -> Result<()>
pub fn invalidate_activity(&self, path: &Path) -> Result<()>
Invalidate activity cache entry for a session file.
Called by file watcher when a session file is modified.
Sourcepub fn get_all_alerts(
&self,
min_severity: Option<&str>,
) -> Result<Vec<StoredAlert>>
pub fn get_all_alerts( &self, min_severity: Option<&str>, ) -> Result<Vec<StoredAlert>>
Get all stored alerts, optionally filtered by minimum severity.
Useful for a global alert view across all analyzed sessions.
Sourcepub fn activity_stats(&self) -> Result<ActivityCacheStats>
pub fn activity_stats(&self) -> Result<ActivityCacheStats>
Get activity cache statistics