Locality¶
Temporal Locality¶
Temporal locality is observed when the same resource is fetched repetitively over time. This can be seen in a loop iterator, which is accessed after each iteration.
Spatial Locality¶
Spacial locality is observed when close-by memory locations are accessed in succession. This is seen while iterating over an array.
The purpose of a cache is to take advantage of both of these localities.