pub fn cached_store_connection(
api_version: &str,
) -> Result<&'static Mutex<Connection>>Expand description
Returns a process-wide, in-memory-backed connection for api_version:
on first access, opens the on-disk file read-only via open_store,
copies its entire contents into a fresh :memory: connection (via
SQLite’s backup API), then drops the on-disk connection immediately —
so its file handle/lock is held only for that brief copy, not for the
process’s lifetime. This means an external process (a fresh
github-mcp-populate-embeddings run, a deployment replacing the file) can update
mcp_store.db without hitting “database is locked” against a live
server, at the cost of the running process only picking up such an
update on its next restart.
Returns the connection behind a Mutex rather than handing it out
directly: callers must finish with the guard (and drop it) before
any .await — rusqlite::Connection isn’t Sync, so holding the
guard across an await point would make the enclosing future
non-Send, the same constraint core/mcp_server.rs’s tool handlers
already respect for a plain Connection.