ContentsThe library

Keeping the Answer Nearby

When the Copy Stops Being True

Last timeDeciding What to Throw Away

A cached answer is true until the real thing changes, and nothing tells the cache that it has. There are only two remedies, a clock and a message, and both of them leak.

Everything so far has treated a cached answer as if it stays correct. It does

not. The moment somebody changes the underlying thing, the copy becomes a lie,

and no part of the system has any reason to tell the cache about it. The cache

will go on serving that answer confidently until something makes it stop.

There are exactly two things that can make it stop.

A clock, or a message

The first remedy is a clock. When the copy is made, you decide how long it may

be used, and after that it is discarded whether or not anything changed. This

needs no cooperation from anybody. It is also always a little wrong, because the

change you care about can happen immediately after the copy was made.

The second remedy is a message. When something writes a new value, it also tells

the cache to drop what it holds. This can be very prompt. It requires that every

writer knows about every cache, that the message gets there, and that it arrives

in a sensible order relative to the write itself. Those are not small

requirements, and this is the part of caching that quietly turns into a

distributed systems problem.

Almost every real system uses both. A message for the cases that matter, and a

clock underneath as a safety net for the messages that go missing.

What an expiry time is really saying

An expiry time is widely misunderstood as a claim about the data. It is not. It

is a bound on how wrong a reader may be.

The lesson stops here

5 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01The Same Thing, Asked Again
  2. 02What You Actually Buy With a Hitopening only
  3. 03Choosing What to Forgetopening only
  4. 04When the Copy Stops Being Trueyou are here
  5. 05Choosing How Far Away to Keep Itopening only
  6. 06The Ways a Cache Turns On Youopening only
  7. 07Many Boxes Pretending to Be Oneopening only
  8. 08Telling Whether It Earns Its Placeopening only

Read alongside