Class AbstractPersistentCache

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, PersistentCache

    public abstract class AbstractPersistentCache
    extends java.lang.Object
    implements PersistentCache, java.io.Closeable
    • Field Detail

      • THREADS

        public static final int THREADS
      • executor

        protected java.util.concurrent.ExecutorService executor
      • cacheSize

        protected java.util.concurrent.atomic.AtomicLong cacheSize
      • writesPending

        protected final java.util.Set<java.lang.String> writesPending
    • Constructor Detail

      • AbstractPersistentCache

        public AbstractPersistentCache()
    • Method Detail

      • readSegment

        public org.apache.jackrabbit.oak.commons.Buffer readSegment​(long msb,
                                                                    long lsb,
                                                                    @NotNull
                                                                    @NotNull java.util.concurrent.Callable<org.apache.jackrabbit.oak.commons.Buffer> loader)
        Description copied from interface: PersistentCache
        Reads the segment from cache.
        Specified by:
        readSegment in interface PersistentCache
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        loader - in case of cache miss, with loader.call() missing element will be retrieved
        Returns:
        byte buffer containing the segment data or null if the segment doesn't exist
      • readSegmentInternal

        protected abstract org.apache.jackrabbit.oak.commons.Buffer readSegmentInternal​(long msb,
                                                                                        long lsb)
        Reads the segment from the cache. If segment is not found, this method does not query next cache that was set with linkWith(AbstractPersistentCache)
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        Returns:
        byte buffer containing the segment data or null if the segment doesn't exist
      • recordCacheLoadTimeInternal

        protected final void recordCacheLoadTimeInternal​(long loadTime,
                                                         boolean successful)
        Records time spent to load data from external source, after cache miss.
        Parameters:
        loadTime - load time in nanoseconds
        successful - indicates whether loading of the segment into cache was successful
      • getCacheStats

        @NotNull
        public @NotNull org.apache.jackrabbit.oak.cache.AbstractCacheStats getCacheStats()
        Returns:
        Statistics for this cache.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • getWritesPending

        public int getWritesPending()