Skip to content

Cache

What is Cache?

A stored copy of data that is faster to read than fetching or calculating the original again.

A cache reuses earlier results. For example, a shop can cache its product list so each visitor does not trigger another database read. Copies can become stale, meaning out of date, so set an expiry and decide when changes must clear them. Check current prices and stock at checkout.

When you would use it

Use it when repeated reads are slow or expensive and you can define how fresh the answer must be.

Common operations

  • Set an expiry for copied data.
  • Clear affected copies when the original changes.

Related terms

Where this is taught

Going deeper