O'Reilly logo

Inside the Machine by Jon Stokes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Locality of Reference

Caching works because of a very simple property exhibited to one degree or another by all types of code and data: locality of reference. We generally find it useful to talk about two types of locality of reference: spatial locality and temporal locality.

Spatial locality

Spatial locality is a fancy label for the general rule that if the CPU needs an item from memory at any given moment, it’s likely to need that item’s neighbors next.

Temporal locality

Temporal locality is the name we give to the general rule that if an item in memory was accessed once, it’s likely to be accessed again in the near future.

Depending on the type of application, both code and data streams can exhibit spatial and temporal locality.

Spatial Locality ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required