Knowledge Maxxing
← Back to topic library
Dev MaxxingAdvancedDistributed Systems75 sec

Cache

A cache stores a copy of data that's expensive to compute or fetch, so future requests for the same data can be served faster from the stored copy instead.

Prerequisite: Database index

What matters

Because a cache serves a stored copy rather than recomputing, it can dramatically improve speed, but it introduces the new risk of ever showing outdated data.

Example

A cache might store the result of a slow database query for one minute, serving that stored result to every request in that window instead of rerunning the query.

Common misconception

Reading from a cache is not guaranteed to return the absolute latest data; a cache can serve a slightly outdated copy until it's refreshed or invalidated.

Recall question

What new risk does a cache introduce in exchange for faster responses?

Keywords and related concepts

cacheperformancestored copycache invalidation

Related topics

Cache invalidation
Dev MaxxingAdvanced
Latency
Dev MaxxingAdvanced