What Is an In-Memory Database? Distinguishing Memory-First Storage from a Cache
An in-memory database keeps its primary working copy of data in RAM and processes reads and writes there. Memory access can reduce storage I/O and help achieve low latency, but RAM capacity and cost are constraints, and preserving data through failures requires a separate durability and recovery design. “In-memory” therefore does not by itself mean volatile, nor does it mean data is automatically safe.
What stays in memory, and why can that be fast?
A database keeps records or indexes in memory so it does not need to fetch them from storage for every request. Memory usually has lower access latency than an SSD, but actual performance also depends on network round trips, query work, concurrency, data structures, and storage settings. An in-memory design does not guarantee that every workload will be fast; measure it against the target load and latency goals.
“In-memory” describes an implementation approach, not one product category or durability policy. Some systems require the whole dataset to remain in RAM; others keep only frequently used data there or combine RAM with flash. For example, Redis Open Source describes a design with the dataset in memory, while Redis products also offer disk-persistence choices depending on configuration. SAP HANA processes data in memory and uses data and log volumes to support recovery. Check the documentation for the specific product and deployment.
Is an in-memory database the same as a cache?
No. A cache usually keeps a copy that can be fetched or rebuilt from a source system, reducing the cost of repeated access. Cache entries may expire or be evicted under memory pressure, and an application can be designed to read the source when an entry is missing. If an in-memory database holds authoritative business records, however, losing data can mean losing business state rather than merely taking a cache miss, so durability, backup, and recovery requirements differ.
Redis documentation also describes using Redis alongside a disk-based database: keep write-heavy or frequently accessed data in Redis and larger data in SQL or another disk-based database. The system must define how changes in the source database and memory store stay aligned. For a simple cache, rebuilding on a miss is central. If both stores participate in authoritative state, design for failed writes, retries, duplicate processing, and reconciliation.
| Use | Role of the in-memory data | Expected behavior after failure or a miss |
|---|---|---|
| Cache | A copy that can be fetched again from the source | Reload from the source after expiry or eviction |
| In-memory source of truth | Records the business depends on | Restore according to durability, backup, and recovery goals |
| Companion to a disk database | A hot subset or write-heavy data | Follow synchronization and replay rules with the source |
Does the data survive a restart?
That depends on the product and configuration. Some deployments can disable disk persistence for cache workloads where losing memory contents is acceptable. Others restore memory state from periodic snapshots, write logs, or both. A snapshot represents a point in time, so changes after the latest snapshot may be missing. A log can preserve changes more granularly, but its performance cost and possible loss window depend on write and synchronization policies.
Redis documentation distinguishes RDB snapshots, AOF (append-only file) logging, and a combined option. These are Redis features, not universal behavior across all in-memory databases. Enabling disk persistence also does not by itself provide sufficient backup. Define recovery goals for storage failure, operator error, corruption, and regional loss, then validate separate backups and restore procedures in practice.
How should you handle capacity limits and memory pressure?
Memory is used not only by data, but also by keys, indexes, object headers, replication buffers, and headroom needed during persistence work. Allocating RAM equal only to the logical data size can hit a limit during a traffic spike or rebuild. Measure representative workloads with realistic data shapes, key counts, indexes, expiry rules, and replication or snapshot settings; leave room for growth and operations.
At a limit, a product may reject writes, remove items under a configured policy, or tier data between memory and flash. Eviction from a cache can reduce performance and cause reads from the source; eviction from authoritative data can lose records. Redis provides a maxmemory limit and several key-eviction policies. Choose behavior according to the data’s role, and monitor memory use, eviction rate, write errors, and latency.
When should you choose one, and what should you check?
Consider an in-memory store for sessions, real-time aggregation, fast lookups, or bounded working data when low latency matters. A disk-centered database may fit better if the dataset is much larger than RAM, storage cost dominates, or storage access meets the workload’s needs. A cache may be enough when only a frequently accessed subset needs acceleration. If the full business dataset must reside in memory and recoverability matters, evaluate an in-memory database with persistence features.
Before deciding, answer these questions:
Is the memory data a cache or authoritative data? What is the business impact of losing it?
What data-loss objective (RPO) and recovery-time objective (RTO) are acceptable after a restart or failure?
Are persistence, replication, backup, and restore supported by this product and service tier?
Have you measured memory capacity and cost for data, indexes, replication, and restart headroom?
At the limit, will writes fail, keys be evicted, or capacity expand—and how will you alert on it?
In a recovery exercise, how will you confirm data freshness and application consistency?
For example, if session data is short-lived and users can sign in again after expiry, a cache-style setup that permits expiry and eviction may be reasonable. If payment state exists only in memory without persistence or a source store, a restart could erase transaction state. This is illustrative; verify actual recovery behavior in the selected product and managed-service documentation and through recovery exercises.
Summary
An in-memory database uses RAM as its main working area, which can help reduce latency but requires joint planning for capacity, cost, and failure recovery. In-memory does not mean volatile, and a cache has different requirements from authoritative data. First define the data’s role, then choose persistence, backup, eviction, recovery, and capacity policies and validate them against failure scenarios.
Sources and scope
[Redis FAQ: in-memory design, memory limits, and using a disk database alongside Redis](https://redis.io/docs/latest/develop/get-started/faq/)
[Redis documentation: data persistence (RDB and AOF)](https://redis.io/docs/latest/management/persistence/)
[Redis documentation: key eviction policies](https://redis.io/docs/latest/develop/reference/eviction/)
[SAP Help Portal: data and log volumes and savepoints](https://help.sap.com/docs/SAP_HANA_PLATFORM/6b94445c94ae495c83a19646e7c3fd56/4a9a3970fb634a319f32bb76e1c59dd5.html)
Official Redis and SAP HANA materials were checked on 2026-11-22. In-memory implementations and persistence features vary by product, version, and deployment. This is not a configuration guide for a specific product; no recovery or performance test was performed. RPO is the acceptable data-loss objective, and RTO is the recovery-time objective.