educative.io

When to use LIFO cache eviction policy?

I can’t think of a benefit of using the Last in First Out policy. It works like a stack and I feel it’s kind of counterintuitive for caching. Can any I give an example of when LIFO is useful?

Thanks

Hi Nedia!
Can you please specify the lesson link where you are confused regarding LIFO policy so that we can better answer your query?
Thank you.

1 Like

Hi @Ali1, Thank you for contacting the Educative team!

Hope you are enjoying a great day. We see only the link to the course but no query. How the Educative team can help you :blush:.

Hope you have an amazing learning experience on Educative!

Hi, @Nedia Thank you for contacting the Educative team!

Yes, When we use the Lifo cache eviction policy, the cache behaves as a stack. When the cache is full and if the processor requests the new block, the last filled block of the cache will be evicted and a new block will be placed on the lastly evicted space and the cache will be again full. Maybe it is not the best approach but it is one of the possibilities to handle that cache.

Hope the answer to your query. Have an amazing learning experience on Educative!