Cache hit (source code)

= Cache hit

A request whose required data are already available in the consulted <memory cache>. In the read-only model of <spatial locality>, a requested <cache block> being resident is sufficient for a <cache hit>.

The <memory access trace> under <memory cache> has <cache hits> at reads 2, 4, 9, 10 and 12. Read 2, at address 4, benefits from the <cache line> fetched by read 1 at address 0; read 9, at address 52, benefits from read 8 at address 48. These reads use different <bytes> of the same <cache blocks>, illustrating <spatial locality>. Read 4 returns to address 0 while its <cache block> remains resident, illustrating <temporal locality>.

A <cache hit> still takes time to identify the matching <cache tag> and obtain the requested <byte>. It is relative to the particular <memory cache> consulted: a <cache miss> in one level may be a <cache hit> in another. The model here has one consulted level and treats a valid matching resident copy as sufficient; it makes no prediction about writes or accesses whose permissions or contents change.