Class SLRUCacheMT<K,V>

java.lang.Object
com._1c.g5.v8.xmdb.impl.SLRUCacheMT<K,V>

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

    • SLRUCacheMT

      public SLRUCacheMT(int pSize, int tSize, boolean processEvict, boolean threadSafe)
      Cache constructor
      Parameters:
      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 Details

    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Get entry set of all values from cache
      Returns:
      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
      Returns:
      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
      Returns:
      the number of values in cache
    • get

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

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

      public V remove(K key)
      Remove specified key from cache
      Parameters:
      key - the key to remove
      Returns:
      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.
      Parameters:
      key - evicting key
      value - evicting valut
    • toString

      public String toString()
      Overrides:
      toString in class Object