Class Cache.BoundAtomicMapCache<K,​V>

  • All Implemented Interfaces:
    Cache<K,​V>
    Enclosing interface:
    Cache<K,​V>

    public static class Cache.BoundAtomicMapCache<K,​V>
    extends java.lang.Object
    implements Cache<K,​V>
    Simple cache implementation based on atomic reference on bound hash map. Cache grows up to the given limit. When it reaches the limit, it's being truncated to zero. Then it starts the next cycle of accumulating key-values until the limit is reached again.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V get​(K key, java.util.function.Supplier<V> onMiss)
      Get the value from cache based by key.
      void setMaxCachedItems​(int maxCachedItems)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BoundAtomicMapCache

        public BoundAtomicMapCache()
    • Method Detail

      • get

        public V get​(K key,
                     java.util.function.Supplier<V> onMiss)
        Description copied from interface: Cache
        Get the value from cache based by key.
        Specified by:
        get in interface Cache<K,​V>
        Parameters:
        key - Key to get a value from the cache
        onMiss - Supplier for a value in case it's missing in cache
      • setMaxCachedItems

        public void setMaxCachedItems​(int maxCachedItems)