Class FDBDirectorySharedCacheManager

java.lang.Object
com.apple.foundationdb.record.lucene.directory.FDBDirectorySharedCacheManager

@API(EXPERIMENTAL) @ThreadSafe public class FDBDirectorySharedCacheManager extends Object
A cache for FDBDirectory blocks that can be shared between record contexts. The scope is the record store. Each directory cache is keyed by the index subspace's suffix relative to the record store plus any grouping key. Additionally, the cache is per directory sequence number. Any transaction that changes the directory must also advance this counter. Only the latest sequence number's cache is retained by this manager, although it is possible that multiple older transactions continue to share one.
  • Field Details

    • SHARED_CACHE_CONTEXT_KEY

      public static final Object SHARED_CACHE_CONTEXT_KEY
  • Constructor Details

    • FDBDirectorySharedCacheManager

      protected FDBDirectorySharedCacheManager(@Nullable Subspace subspace, int maximumSize, int concurrencyLevel, int initialCapacity)
  • Method Details

    • getSubspace

      @Nullable public Subspace getSubspace()
    • getMaximumSize

      public int getMaximumSize()
    • getConcurrencyLevel

      public int getConcurrencyLevel()
    • getInitialCapacity

      public int getInitialCapacity()
    • forContext

      @Nullable public static FDBDirectorySharedCacheManager forContext(@Nonnull FDBRecordContext context)
      Get any shared cache manager for the given context. Note that attaching the cache manager to the context means that the context cannot perform Lucene queries against multiple record stores.
      Parameters:
      context - the record context in which to find the shared cache manager
      Returns:
      the shared cache manager set in the context or null if none has been set
      See Also:
    • setForContext

      public void setForContext(@Nonnull FDBRecordContext context)
      Set the given shared cache manager in the given context.
      Parameters:
      context - the record context in which to put the shared cache manager
    • getCache

      @Nullable public FDBDirectorySharedCache getCache(@Nonnull Tuple key, long sequenceNumber)
      Get a cache for a directory.
      Parameters:
      key - the directory key, including the index prefix and any grouping keys
      sequenceNumber - the sequence number of the directory as read in the current transaction
      Returns:
      a shared cache of null if the sequence number is too old
    • newBuilder

      public static FDBDirectorySharedCacheManager.Builder newBuilder()