Class SLRUCacheMT<K,​V>

  • public class SLRUCacheMT<K,​V>
    extends Object
    Multithread SLRU cache implementation
    • Constructor Detail

      • SLRUCacheMT

        public SLRUCacheMT​(int pSize,
                           int tSize,
                           boolean processEvict,
                           boolean threadSafe)
        Cache constructor
        pSize - size of "protected" buffer of SLRU cache
        tSize - size of "test" buffer of SLRU cache
        processEvict - need to call external evict methods while evicting values from cache
        threadSafe - need to be a thread save cache
    • Method Detail

      • entrySet

        public Set<Map.Entry<K,​V>> entrySet()
        Get entry set of all values from cache
        set of all values from cache
      • evictAll

        public void evictAll()
        Evict all values from cache
      • removeAll

        public Map<K,​V> removeAll()
        Remove all values from cache and return it
        all key/value pair, removed from cache
      • clear

        public void clear()
        Clear (drop) cache
      • size

        public int size()
        Get total number of values in cache
        the number of values in cache
      • get

        public V get​(K key)
        Get value by key
        key - the key
        value or null
      • put

        public V put​(K key,
                     V value)
      • remove

        public V remove​(K key)
        Remove specified key from cache
        key - the key to remove
        assotiated with removed key value or null (if value == null or specified key wasn't found in cache)
      • evict

        protected void evict​(K key,
                             V value)
        Evict process implementation. Specified key/value pair steel be available in cache untill evict process finished. Evict should be thread save. Evict can't be called from the same key in different threads in same time.
        key - evicting key
        value - evicting valut