Class DataLoaderOptions

java.lang.Object
org.dataloader.DataLoaderOptions

@PublicApi public class DataLoaderOptions extends Object
Configuration options for DataLoader instances. This is an immutable class so each time you change a value it returns a new object.
  • Constructor Details

    • DataLoaderOptions

      public DataLoaderOptions()
      Creates a new data loader options with default settings.
  • Method Details

    • newDefaultOptions

      public static DataLoaderOptions newDefaultOptions()
      Returns:
      a new default data loader options that you can then customize
    • newOptions

      public static DataLoaderOptions.Builder newOptions()
      Returns:
      a new default data loader options builder that you can then customize
    • newOptions

      public static DataLoaderOptions.Builder newOptions(DataLoaderOptions otherOptions)
      Copies the options into a new builder
      Returns:
      a new default data loader options builder that you can then customize
    • transform

      public DataLoaderOptions transform(Consumer<DataLoaderOptions.Builder> builderConsumer)
      Will transform the current options in to a builder ands allow you to build a new set of options
      Parameters:
      builderConsumer - the consumer of a builder that has this objects starting values
      Returns:
      a new DataLoaderOptions object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • batchingEnabled

      public boolean batchingEnabled()
      Option that determines whether to use batching (the default), or not.
      Returns:
      true when batching is enabled, false otherwise
    • cachingEnabled

      public boolean cachingEnabled()
      Option that determines whether to use caching of futures (the default), or not.
      Returns:
      true when caching is enabled, false otherwise
    • cachingExceptionsEnabled

      public boolean cachingExceptionsEnabled()
      Option that determines whether to cache exceptional values (the default), or not.

      For short-lived caches (that is request caches) it makes sense to cache exceptions since it's likely the key is still poisoned. However, if you have long-lived caches, then it may make sense to set this to false since the downstream system may have recovered from its failure mode.

      Returns:
      true when exceptional values are cached is enabled, false otherwise
    • cacheKeyFunction

      public Optional<CacheKey> cacheKeyFunction()
      Gets an (optional) function to invoke for creation of the cache key, if caching is enabled.

      If missing the cache key defaults to the key type parameter of the data loader of type K.

      Returns:
      an optional with the function, or empty optional
    • cacheMap

      public Optional<CacheMap<?,?>> cacheMap()
      Gets the (optional) cache map implementation that is used for caching, if caching is enabled.

      If missing a standard LinkedHashMap will be used as the cache implementation.

      Returns:
      an optional with the cache map instance, or empty
    • maxBatchSize

      public int maxBatchSize()
      Gets the maximum number of keys that will be presented to the BatchLoader function before they are split into multiple class
      Returns:
      the maximum batch size or -1 if there is no limit
    • getStatisticsCollector

      public StatisticsCollector getStatisticsCollector()
      Returns:
      the statistics collector to use with these options
    • getBatchLoaderContextProvider

      public BatchLoaderContextProvider getBatchLoaderContextProvider()
      Returns:
      the batch environment provider that will be used to give context to batch load functions
    • valueCache

      public Optional<ValueCache<?,?>> valueCache()
      Gets the (optional) cache store implementation that is used for value caching, if caching is enabled.

      If missing, a no-op implementation will be used.

      Returns:
      an optional with the cache store instance, or empty
    • getValueCacheOptions

      public ValueCacheOptions getValueCacheOptions()
      Returns:
      the ValueCacheOptions that control how the ValueCache will be used
    • getBatchLoaderScheduler

      public BatchLoaderScheduler getBatchLoaderScheduler()
      Returns:
      the BatchLoaderScheduler to use, which can be null
    • getInstrumentation

      public DataLoaderInstrumentation getInstrumentation()
      Returns:
      the DataLoaderInstrumentation to use