Package org.dataloader
Class DataLoaderOptions
java.lang.Object
org.dataloader.DataLoaderOptions
Configuration options for
DataLoader
instances.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private CacheKey
<?> private CacheMap
<?, ?> private boolean
private boolean
private BatchLoaderContextProvider
private int
private static final BatchLoaderContextProvider
private Supplier
<StatisticsCollector> private ValueCache
<?, ?> private ValueCacheOptions
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new data loader options with default settings.Clones the provided data loader options. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Option that determines whether to use batching (the default), or not.Gets an (optional) function to invoke for creation of the cache key, if caching is enabled.cacheMap()
Gets the (optional) cache map implementation that is used for caching, if caching is enabled.boolean
Option that determines whether to use caching of futures (the default), or not.boolean
Option that determines whether to cache exceptional values (the default), or not.int
Gets the maximum number of keys that will be presented to theBatchLoader
function before they are split into multiple classstatic DataLoaderOptions
setBatchingEnabled
(boolean batchingEnabled) Sets the option that determines whether batch loading is enabled.setBatchLoaderContextProvider
(BatchLoaderContextProvider contextProvider) Sets the batch loader environment provider that will be used to give context to batch load functionssetCacheKeyFunction
(CacheKey<?> cacheKeyFunction) Sets the function to use for creating the cache key, if caching is enabled.setCacheMap
(CacheMap<?, ?> cacheMap) Sets the cache map implementation to use for caching, if caching is enabled.setCachingEnabled
(boolean cachingEnabled) Sets the option that determines whether caching is enabled.setCachingExceptionsEnabled
(boolean cachingExceptionsEnabled) Sets the option that determines whether exceptional values are cachedis enabled.setMaxBatchSize
(int maxBatchSize) Sets the maximum number of keys that will be presented to theBatchLoader
function before they are split into multiple classsetStatisticsCollector
(Supplier<StatisticsCollector> statisticsCollector) Sets the statistics collector supplier that will be used with these data loader options.setValueCache
(ValueCache<?, ?> valueCache) Sets the value cache implementation to use for caching values, if caching is enabled.setValueCacheOptions
(ValueCacheOptions valueCacheOptions) Sets theValueCacheOptions
that control how theValueCache
will be usedOptional
<ValueCache<?, ?>> Gets the (optional) cache store implementation that is used for value caching, if caching is enabled.
-
Field Details
-
NULL_PROVIDER
-
batchingEnabled
private boolean batchingEnabled -
cachingEnabled
private boolean cachingEnabled -
cachingExceptionsEnabled
private boolean cachingExceptionsEnabled -
cacheKeyFunction
-
cacheMap
-
valueCache
-
maxBatchSize
private int maxBatchSize -
statisticsCollector
-
environmentProvider
-
valueCacheOptions
-
-
Constructor Details
-
DataLoaderOptions
public DataLoaderOptions()Creates a new data loader options with default settings. -
DataLoaderOptions
Clones the provided data loader options.- Parameters:
other
- the other options instance
-
-
Method Details
-
newOptions
- Returns:
- a new default data loader options that you can then customize
-
batchingEnabled
public boolean batchingEnabled()Option that determines whether to use batching (the default), or not.- Returns:
true
when batching is enabled,false
otherwise
-
setBatchingEnabled
Sets the option that determines whether batch loading is enabled.- Parameters:
batchingEnabled
-true
to enable batch loading,false
otherwise- Returns:
- the data loader options for fluent coding
-
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
-
setCachingEnabled
Sets the option that determines whether caching is enabled.- Parameters:
cachingEnabled
-true
to enable caching,false
otherwise- Returns:
- the data loader options for fluent coding
-
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 its 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
-
setCachingExceptionsEnabled
Sets the option that determines whether exceptional values are cachedis enabled.- Parameters:
cachingExceptionsEnabled
-true
to enable caching exceptional values,false
otherwise- Returns:
- the data loader options for fluent coding
-
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 typeK
.- Returns:
- an optional with the function, or empty optional
-
setCacheKeyFunction
Sets the function to use for creating the cache key, if caching is enabled.- Parameters:
cacheKeyFunction
- the cache key function to use- Returns:
- the data loader options for fluent coding
-
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
-
setCacheMap
Sets the cache map implementation to use for caching, if caching is enabled.- Parameters:
cacheMap
- the cache map instance- Returns:
- the data loader options for fluent coding
-
maxBatchSize
public int maxBatchSize()Gets the maximum number of keys that will be presented to theBatchLoader
function before they are split into multiple class- Returns:
- the maximum batch size or -1 if there is no limit
-
setMaxBatchSize
Sets the maximum number of keys that will be presented to theBatchLoader
function before they are split into multiple class- Parameters:
maxBatchSize
- the maximum batch size- Returns:
- the data loader options for fluent coding
-
getStatisticsCollector
- Returns:
- the statistics collector to use with these options
-
setStatisticsCollector
Sets the statistics collector supplier that will be used with these data loader options. Since it uses the supplier pattern, you can create a new statistics collector on each call or you can reuse a common value- Parameters:
statisticsCollector
- the statistics collector to use- Returns:
- the data loader options for fluent coding
-
getBatchLoaderContextProvider
- Returns:
- the batch environment provider that will be used to give context to batch load functions
-
setBatchLoaderContextProvider
Sets the batch loader environment provider that will be used to give context to batch load functions- Parameters:
contextProvider
- the batch loader context provider- Returns:
- the data loader options for fluent coding
-
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
-
setValueCache
Sets the value cache implementation to use for caching values, if caching is enabled.- Parameters:
valueCache
- the value cache instance- Returns:
- the data loader options for fluent coding
-
getValueCacheOptions
- Returns:
- the
ValueCacheOptions
that control how theValueCache
will be used
-
setValueCacheOptions
Sets theValueCacheOptions
that control how theValueCache
will be used- Parameters:
valueCacheOptions
- the value cache options- Returns:
- the data loader options for fluent coding
-