返信ありがとう!
jasonmp85 が指摘したように、LinkedHashMap にはアクセス順序を許可するコンストラクターがあります。API ドキュメントを見たときに、そのビットを見逃していました。実装も非常に効率的です (以下を参照)。各エントリの最大サイズの上限と組み合わせると、問題が解決するはずです。
SoftReference についても詳しく見ていきます。記録のためだけに、Google Collections は一般的に SoftKeys と SoftValues と Maps のためのかなり良い API を持っているようです。
これは、LRU 動作を維持する方法を示す Java LikedHashMap クラスのスニペットです。
/**
* Removes this entry from the linked list.
*/
private void remove() {
before.after = after;
after.before = before;
}
/**
* Inserts this entry before the specified existing entry in the list.
*/
private void addBefore(Entry<K,V> existingEntry) {
after = existingEntry;
before = existingEntry.before;
before.after = this;
after.before = this;
}
/**
* This method is invoked by the superclass whenever the value
* of a pre-existing entry is read by Map.get or modified by Map.set.
* If the enclosing Map is access-ordered, it moves the entry
* to the end of the list; otherwise, it does nothing.
*/
void recordAccess(HashMap<K,V> m) {
LinkedHashMap<K,V> lm = (LinkedHashMap<K,V>)m;
if (lm.accessOrder) {
lm.modCount++;
remove();
addBefore(lm.header);
}