Code Craft

Software is equal parts Art, Craft, and Engineering

Most-Recently-Used Object Cache

This class is a very simple MRU cache based on my LinkedTree implementation. It serves as a working example of the use of the linked tree. However, do note that it does not leverage one of the most powerful attributes of the tree, which is the ability to position to and navigate from specific nodes by exact and closest-match keys.

This class also contains a thread-safe subclass as an inner class. I am not yet completely decided on whether this is a great approach to the problem of creating a synchronized version of an object, but it seems to have a certain elegance about it.

Date Update
2010-10-23 Make class generic and use soft references instead of hard references.

Get The Source

The source compiles to Java 5.