As the name suggests when the cache memory is full, LRU picks the data that is least recently used and removes it in order to make space for the new data. The priority of the data in the cache changes according to the need of that data i.e. if some data is fetched or updated recently then the priority of that data would be changed and assigned to the highest priority, and the priority of the data decreases if it remains unused operations after operations. We use two data structures to implement an LRU Cache.

Queue is implemented using a doubly-linked list. The maximum size of the queue will be equal to the total number of frames available (cache size). The most recently used pages will be near the front end and the least recently used pages will be near the rear end. A Hash with the page number as key and the address of the corresponding queue node as value.

Built With

  • cpp
  • doubly
  • hashmap
  • linked
  • list
  • queue
Share this project:

Updates

Submission history