Class RecordCache<K>

  • Type Parameters:
    K -
    All Implemented Interfaces:
    Cache<K,​RecordId>

    public abstract class RecordCache<K>
    extends java.lang.Object
    implements Cache<K,​RecordId>
    Partial mapping of keys of type K to values of type RecordId. This is typically used for de-duplicating values that have already been persisted and thus already have a RecordId.
    • Constructor Summary

      Constructors 
      Constructor Description
      RecordCache()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract long estimateCurrentWeight()  
      static <T> @NotNull org.apache.jackrabbit.guava.common.base.Supplier<RecordCache<T>> factory​(int size)  
      static <T> @NotNull org.apache.jackrabbit.guava.common.base.Supplier<RecordCache<T>> factory​(int size, @NotNull org.apache.jackrabbit.guava.common.cache.Weigher<T,​RecordId> weigher)  
      abstract @NotNull org.apache.jackrabbit.guava.common.cache.CacheStats getStats()  
      static <T> @NotNull RecordCache<T> newRecordCache​(int size)
      Factory method for creating RecordCache instances.
      void put​(K key, @NotNull RecordId value, byte cost)
      Add a mapping from key to value with a given cost.
      abstract long size()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.jackrabbit.oak.segment.Cache

        get, put
    • Constructor Detail

      • RecordCache

        public RecordCache()
    • Method Detail

      • size

        public abstract long size()
        Returns:
        number of mappings
      • estimateCurrentWeight

        public abstract long estimateCurrentWeight()
      • put

        public void put​(@NotNull
                        K key,
                        @NotNull
                        @NotNull RecordId value,
                        byte cost)
        Description copied from interface: Cache
        Add a mapping from key to value with a given cost.
        Specified by:
        put in interface Cache<K,​RecordId>
      • getStats

        @NotNull
        public abstract @NotNull org.apache.jackrabbit.guava.common.cache.CacheStats getStats()
        Returns:
        access statistics for this cache
      • newRecordCache

        @NotNull
        public static <T> @NotNull RecordCache<T> newRecordCache​(int size)
        Factory method for creating RecordCache instances. The returned instances are all thread safe. They implement a simple LRU behaviour where the least recently accessed mapping would be replaced when inserting a new mapping would exceed size.
        Returns:
        A new RecordCache instance of the given size.
      • factory

        @NotNull
        public static <T> @NotNull org.apache.jackrabbit.guava.common.base.Supplier<RecordCache<T>> factory​(int size,
                                                                                                            @NotNull
                                                                                                            @NotNull org.apache.jackrabbit.guava.common.cache.Weigher<T,​RecordId> weigher)
        Parameters:
        size - size of the cache
        weigher - Needed to provide an estimation of the cache weight in memory
        Returns:
        A factory returning RecordCache instances of the given size when invoked.
        See Also:
        newRecordCache(int)
      • factory

        @NotNull
        public static <T> @NotNull org.apache.jackrabbit.guava.common.base.Supplier<RecordCache<T>> factory​(int size)
        Parameters:
        size - size of the cache
        Returns:
        A factory returning RecordCache instances of the given size when invoked.
        See Also:
        newRecordCache(int)