Manages SQLite database connections with in-memory storage and file backup.
The Database class provides a wrapper around SQLite that uses an in-memory database for performance, with the ability to backup to and restore from a file. It maintains a schema cache to avoid repeated schema queries.
The database is configured for serialized access mode, allowing safe multi-threaded access.
Thread safety is ensured via a mutex that protects all database operations, allowing safe concurrent access from multiple threads (e.g., main thread and background async query threads).