Class AbstractEvictionPolicy<K,​V>

    • Field Detail

      • memSize

        protected final LongAdder memSize
        Memory size occupied by elements in container.
    • Constructor Detail

      • AbstractEvictionPolicy

        public AbstractEvictionPolicy()
    • Method Detail

      • shrink

        protected void shrink()
        Shrinks backed container to maximum allowed size.
      • onEntryAccessed

        public void onEntryAccessed​(boolean rmv,
                                    EvictableEntry<K,​V> entry)
        Callback for whenever entry is accessed.
        Specified by:
        onEntryAccessed in interface EvictionPolicy<K,​V>
        Parameters:
        rmv - True if entry has been removed, false otherwise.
        entry - Accessed entry.
      • getCurrentSize

        protected abstract int getCurrentSize()
        Returns:
        Size of the container with trackable entries.
      • shrink0

        protected abstract int shrink0()
        Returns:
        Size of the memory which was shrinked.
      • removeMeta

        protected abstract boolean removeMeta​(Object meta)
        Parameters:
        meta - Meta-information shipped to an entry.
        Returns:
        True if meta was successfully removed from the container.
      • touch

        protected abstract boolean touch​(EvictableEntry<K,​V> entry)
        Parameters:
        entry - Entry to touch.
        Returns:
        True if container has been changed by this call.
      • setMaxMemorySize

        public AbstractEvictionPolicy<K,​V> setMaxMemorySize​(long maxMemSize)
        Sets maximum allowed cache size in bytes.
        Parameters:
        maxMemSize - Maximum allowed cache size in bytes.
        Returns:
        this for chaining.
      • getMaxMemorySize

        public long getMaxMemorySize()
        Gets maximum allowed cache size in bytes.
        Returns:
        maximum allowed cache size in bytes.
      • getCurrentMemorySize

        public long getCurrentMemorySize()
        Gets current queue size in bytes.
        Returns:
        current queue size in bytes.
      • setMaxSize

        public AbstractEvictionPolicy<K,​V> setMaxSize​(int max)
        Sets maximum allowed size of cache before entry will start getting evicted.
        Parameters:
        max - Maximum allowed size of cache before entry will start getting evicted.
        Returns:
        this for chaining.
      • getMaxSize

        public int getMaxSize()
        Gets maximum allowed size of cache before entry will start getting evicted.
        Returns:
        Maximum allowed size of cache before entry will start getting evicted.
      • setBatchSize

        public AbstractEvictionPolicy<K,​V> setBatchSize​(int batchSize)
        Sets batch size.
        Parameters:
        batchSize - Batch size.
        Returns:
        this for chaining.
      • getBatchSize

        public int getBatchSize()
        Gets batch size.
        Returns:
        batch size.