Class RangeCache<Key extends java.lang.Comparable<Key>,​Value extends io.netty.util.ReferenceCounted>

  • Type Parameters:
    Key - Cache key. Needs to be Comparable
    Value - Cache value

    public class RangeCache<Key extends java.lang.Comparable<Key>,​Value extends io.netty.util.ReferenceCounted>
    extends java.lang.Object
    Special type of cache where get() and delete() operations can be done over a range of keys.
    • Constructor Detail

      • RangeCache

        public RangeCache()
        Construct a new RangeLruCache with default Weighter.
    • Method Detail

      • put

        public boolean put​(Key key,
                           Value value)
        Insert.
        Parameters:
        key -
        value - ref counted value with at least 1 ref to pass on the cache
        Returns:
        whether the entry was inserted in the cache
      • getRange

        public java.util.Collection<Value> getRange​(Key first,
                                                    Key last)
        Parameters:
        first - the first key in the range
        last - the last key in the range (inclusive)
        Returns:
        a collections of the value found in cache
      • removeRange

        public org.apache.commons.lang3.tuple.Pair<java.lang.Integer,​java.lang.Long> removeRange​(Key first,
                                                                                                       Key last,
                                                                                                       boolean lastInclusive)
        Parameters:
        first -
        last -
        lastInclusive -
        Returns:
        an pair of ints, containing the number of removed entries and the total size
      • evictLeastAccessedEntries

        public org.apache.commons.lang3.tuple.Pair<java.lang.Integer,​java.lang.Long> evictLeastAccessedEntries​(long minSize)
        Parameters:
        minSize -
        Returns:
        a pair containing the number of entries evicted and their total size
      • evictLEntriesBeforeTimestamp

        public long evictLEntriesBeforeTimestamp​(long maxTimestamp)
        Parameters:
        maxTimestamp - the max timestamp of the entries to be evicted
        Returns:
        the tota
      • getNumberOfEntries

        protected long getNumberOfEntries()
        Just for testing. Getting the number of entries is very expensive on the conncurrent map
      • getSize

        public long getSize()
      • clear

        public long clear()
        Remove all the entries from the cache.
        Returns:
        size of removed entries