The In Memory Database
An in memory database keeps its working data in RAM rather than on disk. Because memory access is far faster than disk, these systems serve reads and writes with very low latency, which suits caches, leaderboards, and session stores.
Speed and its cost
RAM is fast but volatile: when the power drops, its contents vanish. An in memory database must therefore choose how much durability it wants:
- Snapshots periodically write the whole dataset to disk, so a crash loses only the work since the last snapshot.
- An append only log records each change, so the database can replay it to rebuild state.
- Some systems accept losing the most recent moments in exchange for maximum speed.
Data structures over rows
Many in memory databases expose rich structures like lists, sets, sorted sets, and hashes directly, instead of only tables. Operating on these in memory makes patterns like ranking and queuing simple and fast.
Key idea
An in memory database trades durable disk storage for the speed of RAM, then adds snapshots or logs so a crash does not erase everything.