01: package ri.cache.eviction;
02:
03: import javax.cache.CacheEntry;
04:
05: public class LFUChainEvictionStrategy<K, V> extends
06: LRUChainEvictionStrategy<K, V> {
07:
08: public CacheEntry<K, V> createEntry(K key, V value, long ttl) {
09: return new Entry(key, value, ttl);
10: }
11:
12: protected class Entry extends LRUChainEvictionStrategy<K, V>.Entry {
13: public Entry(K key, V value, long ttl) {
14: super (key, value, ttl);
15: }
16:
17: public void touch() {
18: synchronized (header) {
19: if (previous == header)
20: return;
21: previous.next = next;
22: next.previous = previous;
23: // @@@ REVIEW BG: I don't think this is right, the current entry is still not in the chain.
24: previous = previous.previous;
25: next = next.previous;
26: }
27: }
28:
29: public void discard() {
30: synchronized (header) {
31: this.previous.next = this.next;
32: this.next.previous = this.previous;
33: }
34: }
35: }
36:
37: }
|