Class PersistentCachePreloadingConfiguration


  • public class PersistentCachePreloadingConfiguration
    extends Object
    Configuration for a segment preload mechanism that preloads segments into a PersistentCache. The preload mechanism is triggered whenever a segment in the cache is {@link PersistentCache#readSegment(long, long, Callable)|accessed}. When this happens, all segments referenced by the accessed segment are asynchronously preloaded.

    Next to the concurrency level, i.e. how many threads are used for preloading, the maxPreloadDepth (default: 1, which controls how many recursive levels of referenced segments are preloaded, can be configured.

    Prefetching is done asynchronously, but it may add some overhead. It is primarily recommended to parallelize slow I/O, e.g. when using a remote persistence.

    Different scenarios may warrant different preloading strategies. A short-lived process traversing a repository (e.g. copy, offline-compaction) with an initially empty cache may benefit from a more threads and a higher preload-depth, while a long-running process, e.g. a web application, may perform better with fewer threads and a lower preload depth.

    • Method Detail

      • withMaxPreloadDepth

        public PersistentCachePreloadingConfiguration withMaxPreloadDepth​(int maxPreloadDepth)
        Set how many recursive levels of referenced segments should be preloaded.
        Parameters:
        maxPreloadDepth - depth of the preloading, i.e. how many levels of referenced segments should be preloaded (default: 1)
        Returns:
        this configuration
      • getConcurrency

        public int getConcurrency()
      • getMaxPreloadDepth

        public int getMaxPreloadDepth()