A Cache (pronounced as cash) in computer engineering, enables the processing units of computers to minimize the average time that the computer requires in order to access the memory. The cache is a very small and quite fast memory space which provides storage for the data and information from the memory locations that are mostly used in the main memory.
It is a fact that when most accesses of memory are cached memory locations, the required average latency to access these memory locations is much closer to the latency of the cache rather than the main memory latency.
Ordinarily, before the computer processor can read from or even write to a memory location in the computer’s main memory, it must first make sure that it checks whether a copy of the data exists in the cache or not. If and when a copy of the data does exist in the cache, then the processor will opt to read from or write to the cache. This is much faster than when the processor reads or writes to the main memory of the computer. Below are some images of cache memories.
Many modern computers have nowadays been designed with a number of three caches that are independent. The three caches are;
1. Instruction cache
Instruction caches are very similar to the data caches with the only difference being that the central processing unit performs read access (the fetch instructions) only on this type of cache.
2. Data Cache
This is the most used type of cache. The data cache is used to speed up the fetching of data and its storage. The data and instruction caches can be combined in order to reduce the cost in overhead when they are separated.
3. Translation lookaside buffer
This is a very important cache that is primarily used to speed the translation of virtual addresses to physical one for executable statements (instructions) and the data.
The hardware components of a computer usually implement caches as blocks of memory that is used for the purpose of temporary storage of the data that is most likely to be used again. The Central Processing Unit (CPU), the hard drives and web browsers and servers all frequently use cache. A computer (CPU) cache is usually made up of a number of entries with each having a datum. A datum (data nugget) is a just a copy of a similar datum in a back storage. The entries also have tags. The tags are responsible for identifying the datum in the backup storage which is the copy of the entry.
When the processor wants to read from memory and check for a copy of the data in the cache and finds it, it uses the datum in the entry. This is a condition called a cache hit. If there is no copy of the data in the cache, the condition is called a cache miss. During this situation the processor employs some algorithms to determine which datum will be deleted from the cache to give room for the new entries.