Replacement policies
Replacement Policies for Cache Design A replacement policy dictates when the cache should be invalidated when the system requires data that is not in the ca...
Replacement Policies for Cache Design A replacement policy dictates when the cache should be invalidated when the system requires data that is not in the ca...
Replacement Policies for Cache Design
A replacement policy dictates when the cache should be invalidated when the system requires data that is not in the cache. There are two primary replacement policies commonly used in cache design: LRU (Least Recently Used) and FIFO (First In, First Out).
Least Recently Used (LRU)
In the LRU replacement policy, the cache is invalidated when the cache hit rate reaches a pre-determined value (usually around 80%). This means that the cache contents are considered stale and need to be replaced with the least recently used data. This policy ensures that the cache is always filled with the most recently used data, but it can lead to cache eviction if the system needs to access data that was previously in the cache.
First In, First Out (FIFO)
The FIFO replacement policy maintains the order in which data was loaded into the cache. This means that the cache is invalidated when the next data item to be loaded is the oldest one in the cache. This policy ensures that the oldest data items are always replaced first, but it can lead to cache invalidation even if the data items are still valid.
Examples
An LRU replacement policy would be used when a large amount of data is being stored in a cache that is frequently accessed.
A FIFO replacement policy would be used when the cache is used to store frequently changing data.
Additional Points
Another replacement policy is implemented in some systems called Least Recently Used with a bias (LRU-B). In this policy, the cache is invalidated when the cache hit rate is below a certain value.
The choice of replacement policy depends on the specific requirements of the system and the data that is being cached