Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What data structure should I use to keep track of recently used items?

I need something like a bounded queue where I can only insert say 10 elements. A new element should override the last inserted element. There should be only n distinct elements

I am looking for suggestions in Java by the way.


1 Answers

ITYM an implementation of a LRU algorithm.

  • How to set up a simple LRU cache using LinkedHashMap

  • Simple LRU Caching with Expiration

like image 97
dirkgently Avatar answered Oct 23 '25 01:10

dirkgently



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!