Spatial locality
The idea that, if a program reads some data, it will probably soon read its neighbors. That's why the cache brings whole blocks, called lines. Temporal locality is the idea that used data gets used again soon.
Example
With 64-byte lines, reading one 4-byte integer from an array also brings the next 15.
Test yourself: Spatial locality
Memory and cache
You read element 0 of an integer array. What else does the cache bring?
With 64-byte lines and 4-byte integers, elements 0 to 15 come together. Reading element 1 next is a hit.
0/1
â–¶ Play