Skip to main content

> Term

cache

A fast, temporary storage layer that serves data quickly, often trading perfect accuracy for speed.

Detailed Explanation

A temporary high-speed data storage layer that stores a subset of data so future requests can be served faster than querying the primary database.

While caching drastically improves performance and reduces database load, it introduces one of computing's hardest problems: cache invalidation (knowing when the temporary data is no longer true).

Why It Matters

It shields primary databases from catastrophic load, but introduces system state ambiguity and eventual consistency challenges.

Common Failure Mode

A cache fails to invalidate after an update, causing users to see stale data, or a 'cache stampede' occurs when a cache expires under heavy load and crushes the underlying database.

Practical Example

Storing a frequently accessed user profile in Redis for 5 minutes to prevent hitting the PostgreSQL database on every page reload.

Production Manifestation

In-memory stores like Redis or Memcached, CDN edge caching, and browser-level local storage.

Frequently Asked Questions

What is cache in short?

A fast, temporary storage layer that serves data quickly, often trading perfect accuracy for speed.

What is the most common failure mode?

A cache fails to invalidate after an update, causing users to see stale data, or a 'cache stampede' occurs when a cache expires under heavy load and crushes the underlying database.

AI Summary

A fast, temporary storage layer that serves data quickly, often trading perfect accuracy for speed. It shields primary databases from catastrophic load, but introduces system state ambiguity and eventual consistency challenges.