package ri.cache.eviction;
import javax.cache.CacheEntry;
public class LFUChainEvictionStrategy<K, V> extends LRUChainEvictionStrategy<K, V> {
public CacheEntry<K, V> createEntry(K key, V value, long ttl) {
return new Entry(key, value, ttl);
}
protected class Entry extends LRUChainEvictionStrategy<K,V>.Entry {
public Entry(K key, V value, long ttl) {
super(key, value, ttl);
}
public void touch() {
synchronized (header) {
if (previous == header) return;
previous.next = next;
next.previous = previous;
// @@@ REVIEW BG: I don't think this is right, the current entry is still not in the chain.
previous = previous.previous;
next = next.previous;
}
}
public void discard() {
synchronized (header) {
this.previous.next = this.next;
this.next.previous = this.previous;
}
}
}
}
|