No, Apache Cassandra is not purely an in-memory database. It is a distributed NoSQL database designed for managing large amounts of structured data across commodity servers. However, it does use caching mechanisms to improve performance.
While Cassandra stores all its data on disk for durability, it utilizes memory (RAM) for caching purposes, and to serve as much read traffic as possible. In particular, it uses:
That said, Cassandra does have an option for creating tables with a 'COMPACT STORAGE' directive which will store the table data in-memory, but it's not recommended for large datasets due to the limitations of RAM.
Here is an example of how to create such an in-memory table:
CREATE TABLE users ( user_id int PRIMARY KEY, name text, email text ) WITH compaction = {'class': 'SizeTieredCompactionStrategy'} AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'};
This instructs Cassandra to cache all keys and rows for this specific table. Note that doing so may lead to larger JVM heap usage. Starting from Cassandra 3.0, off-heap memory is also used to handle certain tasks, reducing pressure on the JVM garbage collector.
Remember that while in-memory tables can provide faster access times, they are still not purely "in-memory databases". Data is written back to disk regularly to ensure durability, so you should ensure your servers have enough disk space.
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.