Code : MRU Cache
Most-Recently-Used 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.
Get The Source
The package statement has been stripped from the source for convenience. I do not advocate unpackaged
classes - you should add a package according to your own requirements.
The source compiles to Java 2.
Download MruCache.java (Total downloads: 132)