Class ReaderCache<T>

  • Direct Known Subclasses:
    StringCache, TemplateCache

    public abstract class ReaderCache<T>
    extends java.lang.Object
    A cache consisting of a fast and slow component. The fast cache for small items is based on an array, and a slow one uses a LIRS cache.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ReaderCache​(long maxWeight, int averageWeight, @NotNull java.lang.String name, @NotNull org.apache.jackrabbit.guava.common.cache.Weigher<org.apache.jackrabbit.oak.segment.ReaderCache.CacheKey,​T> weigher)
      Create a new string cache.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear the cache.
      T get​(long msb, long lsb, int offset, org.apache.jackrabbit.guava.common.base.Function<java.lang.Integer,​T> loader)
      Get the value, loading it if necessary.
      @NotNull CacheStats getStats()  
      protected abstract boolean isSmall​(T value)
      Determine whether the entry is small, in which case it can be kept in the fast cache.
      • Methods inherited from class java.lang.Object

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

      • ReaderCache

        protected ReaderCache​(long maxWeight,
                              int averageWeight,
                              @NotNull
                              @NotNull java.lang.String name,
                              @NotNull
                              @NotNull org.apache.jackrabbit.guava.common.cache.Weigher<org.apache.jackrabbit.oak.segment.ReaderCache.CacheKey,​T> weigher)
        Create a new string cache.
        Parameters:
        maxWeight - the maximum memory in bytes.
        averageWeight - an estimate for the average weight of the elements in the cache. See CacheLIRS.setAverageMemory(int).
        weigher - Needed to provide an estimation of the cache weight in memory
    • Method Detail

      • getStats

        @NotNull
        public @NotNull CacheStats getStats()
      • get

        @NotNull
        public T get​(long msb,
                     long lsb,
                     int offset,
                     org.apache.jackrabbit.guava.common.base.Function<java.lang.Integer,​T> loader)
        Get the value, loading it if necessary.
        Parameters:
        msb - the msb of the segment
        lsb - the lsb of the segment
        offset - the offset
        loader - the loader function
        Returns:
        the value
      • clear

        public void clear()
        Clear the cache.
      • isSmall

        protected abstract boolean isSmall​(T value)
        Determine whether the entry is small, in which case it can be kept in the fast cache.