In-memory caching uses RAM to hold data that applications expect to access repeatedly. Reading a cached value can avoid a database query, a remote API call, or an expensive calculation. Typical examples include product descriptions, configuration values, user profile summaries, and aggregated dashboard results. The cache usually contains a subset of the application's data rather than replacing its authoritative database.
A common implementation is cache-aside, also called lazy loading. An application first checks the cache using a key, such as a product identifier. If the value exists, the request is a cache hit. If it does not, the request is a cache miss: the application retrieves the data from its source, stores a copy in the cache, and returns the result. For example, an online store can cache a product description so thousands of shoppers do not trigger the same database query.
Cloud applications can use local caches inside application processes or a shared cache accessed over the network. Local caches avoid a network request but maintain separate copies on each application instance. A shared cache lets multiple instances reuse the same entries, although network latency, connection limits, and service availability become part of the request path. Managed caching services handle infrastructure tasks, but application code generally still determines what to cache and how to keep it current.
Freshness is a central trade-off. A time to live, or TTL, limits how long an entry remains valid, but it does not guarantee that the value matches the database before expiration. Applications may invalidate or update entries when source data changes. For a product description, brief staleness might be acceptable; for an inventory reservation or payment authorization, an old cached value can cause incorrect decisions. Such operations need an authoritative check or a carefully designed consistency strategy.
Memory is finite and generally more expensive per unit of capacity than disk storage. When capacity is exhausted, a cache may evict entries according to its configured policy or reject writes. Measure hit ratio, request latency, memory usage, evictions, and backend load together. A high hit ratio alone does not prove that caching improves performance if cache lookups are costly or the cached operations were already inexpensive.
Cache failures and simultaneous expirations can suddenly send many requests to the backend, a situation often called a cache stampede. Request coalescing, staggered expiration times, bounded retries, and controlled fallback traffic can reduce this risk. Cached data also needs appropriate access controls, network isolation, and encryption where supported, especially when it includes personal information.
For certification questions, recognize Amazon ElastiCache as an AWS service for managed in-memory caching using engines such as Valkey, Redis OSS, and Memcached. Do not equate all memory-based databases with disposable caches: some provide durability mechanisms and can serve as primary databases. Likewise, replication improves availability but does not by itself guarantee that every acknowledged write survives a failure.