LFUChainEvictionStrategy.java :  » 6.0-JDK-Modules » jsr107 » ri » cache » eviction » Java Open Source

Java Open Source » 6.0 JDK Modules » jsr107 
jsr107 » ri » cache » eviction » LFUChainEvictionStrategy.java
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;
            }
        }
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.