MollyCache is a high-performance, in-memory SQL database with row-based caching capabilities, designed for SQLite compatibility.
- Rust v1.88.0 or higher
- Optionally, for testing, the
tarpaulincrate (install withcargo install tarpaulin)
To run the MollyCache interactive CLI:
cargo runTo run the entire test suite:
cargo testTo get estimated test coverage (requires the tarpaulin crate):
cargo tarpaulinMollyCache is currently in early development. Many planned features are not yet implemented.
Implemented and planned features are tracked through GitHub Issues.
- Performance: MollyCache aims to be significantly more performant than traditional disk-based SQL databases (MySQL, Postgres, SQLite) with performance comparable to in-memory cache stores (Memcached, Redis).
- In-Memory First: MollyCache lives in-memory; disk I/O is only performed at direct request of the user (e.g., snapshotting).
- SQLite Compatibility: MollyCache works towards complete parity with SQLite—queries should have full compatibility and produce the same results.
- High Test Coverage: MollyCache maintains a test coverage goal of >75%.
- Zero Dependencies: MollyCache remains dependency-free, using only Rust standard library functions.
MollyCache's primary use case is to function as an intelligent query cache. Unlike traditional query caches that store complete query results, MollyCache caches and evicts individual rows in its in-memory database.
Why row-based caching? Many queries exist as subsets of one or more other queries.
- Product preview page loads:
SELECT id, name, price FROM products ORDER BY created_at DESC LIMIT 10; - User hovers over products:
SELECT image, colors FROM products WHERE id IN (123, 124, 125); - User clicks a product:
SELECT name, image, price, colors FROM products WHERE id = 123;
In a traditional query cache, these would be stored as three separate objects despite the third query's results being a subset of the first two. With MollyCache, the results of the first and second queries would be cached as rows, making the third query a cache hit.
Complete parity with SQLite allows you to load schemas and data from SQLite databases to use as a data source, with configurable snapshot backup intervals and fetch intervals.
The entire database is built to be atomic and thread-safe, allowing for concurrent reads. Forking is also supported at the risk of loss of data synchronization between forks.
Contributions and ideas are welcome! Current progress is tracked using the issues tab on GitHub.
Code contributions must be properly formatted before being merged. Run the formatter with cargo fmt --all.