public class CacheConfigurationBuilder<K,V> extends java.lang.Object implements Builder<CacheConfiguration<K,V>>
CacheConfigurationBuilder enables building CacheConfigurations using a fluent style.
As with all Ehcache builders, all instances are immutable and calling any method on the builder will return a new instance without modifying the one on which the method was called. This enables the sharing of builder instances without any risk of seeing them modified by code elsewhere.
| Modifier and Type | Method and Description |
|---|---|
CacheConfigurationBuilder<K,V> |
add(Builder<? extends ServiceConfiguration<?>> configurationBuilder)
Convenience method to add a
ServiceConfiguration that is produced by a Builder. |
CacheConfigurationBuilder<K,V> |
add(ServiceConfiguration<?> configuration)
Adds a
ServiceConfiguration to the returned builder. |
CacheConfiguration<K,V> |
build()
Builds an instance.
|
CacheConfigurationBuilder<K,V> |
clearAllServiceConfig()
Clears all
ServiceConfigurations from the returned builder. |
<T extends ServiceConfiguration<?>> |
getExistingServiceConfiguration(java.lang.Class<T> clazz)
Returns the first
ServiceConfiguration with type matching the class passed in. |
<T extends ServiceConfiguration<?>> |
getExistingServiceConfigurations(java.lang.Class<T> clazz)
Returns all
ServiceConfigurations of type matching the class passed in. |
boolean |
hasConfiguredExpiry()
Indicates whether this builder has configured expiry or not.
|
static <K,V> CacheConfigurationBuilder<K,V> |
newCacheConfigurationBuilder(CacheConfiguration<K,V> configuration)
Creates a new instance ready to produce a
CacheConfiguration functionally equivalent to the supplied configuration. |
static <K,V> CacheConfigurationBuilder<K,V> |
newCacheConfigurationBuilder(java.lang.Class<K> keyType,
java.lang.Class<V> valueType,
Builder<? extends ResourcePools> resourcePoolsBuilder)
Creates a new instance ready to produce a
CacheConfiguration with key type <K> and with value type
<V> and which will use the configured resources, passed as a ResourcePoolsBuilder. |
static <K,V> CacheConfigurationBuilder<K,V> |
newCacheConfigurationBuilder(java.lang.Class<K> keyType,
java.lang.Class<V> valueType,
ResourcePools resourcePools)
Creates a new instance ready to produce a
CacheConfiguration with key type <K> and with value type
<V> and which will use the configured resources. |
CacheConfigurationBuilder<K,V> |
remove(ServiceConfiguration<?> configuration)
Removes a
ServiceConfiguration from the returned builder. |
CacheConfigurationBuilder<K,V> |
withClassLoader(java.lang.ClassLoader classLoader)
Adds a
ClassLoader to the returned builder. |
CacheConfigurationBuilder<K,V> |
withDiskStoreThreadPool(java.lang.String threadPoolAlias,
int concurrency)
Adds a
ServiceConfiguration for the OffHeapDiskStore.Provider
indicating thread pool alias and write concurrency. |
CacheConfigurationBuilder<K,V> |
withDispatcherConcurrency(int dispatcherConcurrency)
Adds
StoreEventSourceConfiguration with the specified dispatcher concurrency
to the configured builder. |
CacheConfigurationBuilder<K,V> |
withEventListenersThreadPool(java.lang.String threadPoolAlias)
Adds a
ServiceConfiguration for the CacheEventDispatcherFactory specifying
the thread pool alias to use. |
CacheConfigurationBuilder<K,V> |
withEvictionAdvisor(EvictionAdvisor<? super K,? super V> evictionAdvisor)
Adds an
EvictionAdvisor to the returned builder. |
CacheConfigurationBuilder<K,V> |
withExpiry(Expiry<? super K,? super V> expiry)
Deprecated.
Use
withExpiry(ExpiryPolicy) instead |
CacheConfigurationBuilder<K,V> |
withExpiry(ExpiryPolicy<? super K,? super V> expiry)
Adds
ExpiryPolicy configuration to the returned builder. |
CacheConfigurationBuilder<K,V> |
withKeyCopier(java.lang.Class<? extends Copier<K>> keyCopierClass)
Adds by-value semantic using the provided
Copier class for the key on heap. |
CacheConfigurationBuilder<K,V> |
withKeyCopier(Copier<K> keyCopier)
Adds by-value semantic using the provided
Copier for the key on heap. |
CacheConfigurationBuilder<K,V> |
withKeySerializer(java.lang.Class<? extends Serializer<K>> keySerializerClass)
Adds a
Serializer class for cache keys to the configured builder. |
CacheConfigurationBuilder<K,V> |
withKeySerializer(Serializer<K> keySerializer)
Adds a
Serializer for cache keys to the configured builder. |
CacheConfigurationBuilder<K,V> |
withKeySerializingCopier()
Adds by-value semantic using the cache key serializer for the key on heap.
|
CacheConfigurationBuilder<K,V> |
withLoaderWriter(CacheLoaderWriter<K,V> loaderWriter)
Adds a
CacheLoaderWriter to the configured builder. |
CacheConfigurationBuilder<K,V> |
withLoaderWriter(java.lang.Class<CacheLoaderWriter<K,V>> loaderWriterClass,
java.lang.Object... arguments)
Adds a
CacheLoaderWriter configured through a class and optional constructor arguments to the configured
builder. |
CacheConfigurationBuilder<K,V> |
withResilienceStrategy(java.lang.Class<? extends ResilienceStrategy> resilienceStrategyClass,
java.lang.Object... arguments)
Adds a
ResilienceStrategy configured through a class and optional constructor arguments to the configured
builder. |
CacheConfigurationBuilder<K,V> |
withResilienceStrategy(ResilienceStrategy<K,V> resilienceStrategy)
Adds a
ResilienceStrategy to the configured builder. |
CacheConfigurationBuilder<K,V> |
withResourcePools(ResourcePools resourcePools)
Adds the
ResourcePools to the returned builder. |
CacheConfigurationBuilder<K,V> |
withResourcePools(ResourcePoolsBuilder resourcePoolsBuilder)
Convenience method to add a
ResourcePools through a ResourcePoolsBuilder to the returned builder. |
CacheConfigurationBuilder<K,V> |
withSizeOfMaxObjectGraph(long size)
Adds or updates the
DefaultSizeOfEngineConfiguration with the specified object graph maximum size to the configured
builder. |
CacheConfigurationBuilder<K,V> |
withSizeOfMaxObjectSize(long size,
MemoryUnit unit)
Adds or updates the
DefaultSizeOfEngineConfiguration with the specified maximum mapping size to the configured
builder. |
CacheConfigurationBuilder<K,V> |
withValueCopier(java.lang.Class<? extends Copier<V>> valueCopierClass)
Adds by-value semantic using the provided
Copier class for the value on heap. |
CacheConfigurationBuilder<K,V> |
withValueCopier(Copier<V> valueCopier)
Adds by-value semantic using the provided
Copier for the value on heap. |
CacheConfigurationBuilder<K,V> |
withValueSerializer(java.lang.Class<? extends Serializer<V>> valueSerializerClass)
Adds a
Serializer class for cache values to the configured builder. |
CacheConfigurationBuilder<K,V> |
withValueSerializer(Serializer<V> valueSerializer)
Adds a
Serializer for cache values to the configured builder. |
CacheConfigurationBuilder<K,V> |
withValueSerializingCopier()
Adds by-value semantic using the cache value serializer for the value on heap.
|
public static <K,V> CacheConfigurationBuilder<K,V> newCacheConfigurationBuilder(java.lang.Class<K> keyType, java.lang.Class<V> valueType, ResourcePools resourcePools)
CacheConfiguration with key type <K> and with value type
<V> and which will use the configured resources.K - the key typeV - the value typekeyType - the key typevalueType - the value typeresourcePools - the resources to useCacheConfigurationBuilderpublic static <K,V> CacheConfigurationBuilder<K,V> newCacheConfigurationBuilder(java.lang.Class<K> keyType, java.lang.Class<V> valueType, Builder<? extends ResourcePools> resourcePoolsBuilder)
CacheConfiguration with key type <K> and with value type
<V> and which will use the configured resources, passed as a ResourcePoolsBuilder.K - the key typeV - the value typekeyType - the key typevalueType - the value typeresourcePoolsBuilder - the resources to use, as a builderCacheConfigurationBuilderpublic static <K,V> CacheConfigurationBuilder<K,V> newCacheConfigurationBuilder(CacheConfiguration<K,V> configuration)
CacheConfiguration functionally equivalent to the supplied configuration.K - the key typeV - the value typeconfiguration - seed configurationCacheConfigurationBuilderpublic CacheConfigurationBuilder<K,V> add(ServiceConfiguration<?> configuration)
ServiceConfiguration to the returned builder.configuration - the service configuration to addpublic CacheConfigurationBuilder<K,V> add(Builder<? extends ServiceConfiguration<?>> configurationBuilder)
ServiceConfiguration that is produced by a Builder.configurationBuilder - the service configuration to add, Builder.build() will be called on itadd(ServiceConfiguration)public CacheConfigurationBuilder<K,V> withEvictionAdvisor(EvictionAdvisor<? super K,? super V> evictionAdvisor)
EvictionAdvisor to the returned builder.evictionAdvisor - the eviction advisor to be usedpublic CacheConfigurationBuilder<K,V> remove(ServiceConfiguration<?> configuration)
ServiceConfiguration from the returned builder.configuration - the service configuration to removepublic CacheConfigurationBuilder<K,V> clearAllServiceConfig()
ServiceConfigurations from the returned builder.public <T extends ServiceConfiguration<?>> T getExistingServiceConfiguration(java.lang.Class<T> clazz)
ServiceConfiguration with type matching the class passed in.T - the type of the service configurationclazz - the service configuration classnull if none can be foundpublic <T extends ServiceConfiguration<?>> java.util.List<T> getExistingServiceConfigurations(java.lang.Class<T> clazz)
ServiceConfigurations of type matching the class passed in.T - the type of the service configurationclazz - the service configuration classpublic CacheConfigurationBuilder<K,V> withClassLoader(java.lang.ClassLoader classLoader)
ClassLoader to the returned builder.
The ClassLoader will be used for resolving all non Ehcache types.
classLoader - the class loader to usepublic CacheConfigurationBuilder<K,V> withResourcePools(ResourcePools resourcePools)
ResourcePools to the returned builder.
ResourcePools is what determines the tiering of a cache.
resourcePools - the resource pools to usepublic CacheConfigurationBuilder<K,V> withResourcePools(ResourcePoolsBuilder resourcePoolsBuilder)
ResourcePools through a ResourcePoolsBuilder to the returned builder.resourcePoolsBuilder - the builder providing the resource poolwithResourcePools(ResourcePools)@Deprecated public CacheConfigurationBuilder<K,V> withExpiry(Expiry<? super K,? super V> expiry)
withExpiry(ExpiryPolicy) insteadExpiry configuration to the returned builder.
Expiry is what controls data freshness in a cache.
expiry - the expiry to usepublic CacheConfigurationBuilder<K,V> withExpiry(ExpiryPolicy<? super K,? super V> expiry)
ExpiryPolicy configuration to the returned builder.
ExpiryPolicy is what controls data freshness in a cache.
expiry - the expiry to usepublic boolean hasConfiguredExpiry()
true if expiry configured, false otherwisepublic CacheConfigurationBuilder<K,V> withLoaderWriter(CacheLoaderWriter<K,V> loaderWriter)
CacheLoaderWriter to the configured builder.
Configuration of a CacheLoaderWriter is what enables cache-through patterns.
loaderWriter - the loaderwriter to usepublic CacheConfigurationBuilder<K,V> withLoaderWriter(java.lang.Class<CacheLoaderWriter<K,V>> loaderWriterClass, java.lang.Object... arguments)
CacheLoaderWriter configured through a class and optional constructor arguments to the configured
builder.
Configuration of a CacheLoaderWriter is what enables cache-through patterns.
loaderWriterClass - the loaderwrite classarguments - optional constructor argumentspublic CacheConfigurationBuilder<K,V> withResilienceStrategy(ResilienceStrategy<K,V> resilienceStrategy)
ResilienceStrategy to the configured builder.resilienceStrategy - the resilience strategy to usepublic CacheConfigurationBuilder<K,V> withResilienceStrategy(java.lang.Class<? extends ResilienceStrategy> resilienceStrategyClass, java.lang.Object... arguments)
ResilienceStrategy configured through a class and optional constructor arguments to the configured
builder.resilienceStrategyClass - the resilience strategy classarguments - optional constructor argumentspublic CacheConfigurationBuilder<K,V> withKeySerializingCopier()
Copiers are what enable control of by-reference / by-value semantics for on-heap tier.
public CacheConfigurationBuilder<K,V> withValueSerializingCopier()
Copiers are what enable control of by-reference / by-value semantics for on-heap tier.
public CacheConfigurationBuilder<K,V> withKeyCopier(Copier<K> keyCopier)
Copier for the key on heap.
Copiers are what enable control of by-reference / by-value semantics for on-heap tier.
keyCopier - the key copier to usepublic CacheConfigurationBuilder<K,V> withKeyCopier(java.lang.Class<? extends Copier<K>> keyCopierClass)
Copier class for the key on heap.
Copiers are what enable control of by-reference / by-value semantics for on-heap tier.
keyCopierClass - the key copier class to usepublic CacheConfigurationBuilder<K,V> withValueCopier(Copier<V> valueCopier)
Copier for the value on heap.
Copiers are what enable control of by-reference / by-value semantics for on-heap tier.
valueCopier - the value copier to usepublic CacheConfigurationBuilder<K,V> withValueCopier(java.lang.Class<? extends Copier<V>> valueCopierClass)
Copier class for the value on heap.
Copiers are what enable control of by-reference / by-value semantics for on-heap tier.
valueCopierClass - the value copier class to usepublic CacheConfigurationBuilder<K,V> withKeySerializer(Serializer<K> keySerializer)
Serializer for cache keys to the configured builder.
Serializers are what enables cache storage beyond the heap tier.
keySerializer - the key serializer to usepublic CacheConfigurationBuilder<K,V> withKeySerializer(java.lang.Class<? extends Serializer<K>> keySerializerClass)
Serializer class for cache keys to the configured builder.
Serializers are what enables cache storage beyond the heap tier.
keySerializerClass - the key serializer to usepublic CacheConfigurationBuilder<K,V> withValueSerializer(Serializer<V> valueSerializer)
Serializer for cache values to the configured builder.
Serializers are what enables cache storage beyond the heap tier.
valueSerializer - the key serializer to usepublic CacheConfigurationBuilder<K,V> withValueSerializer(java.lang.Class<? extends Serializer<V>> valueSerializerClass)
Serializer class for cache values to the configured builder.
Serializers are what enables cache storage beyond the heap tier.
valueSerializerClass - the key serializer to usepublic CacheConfigurationBuilder<K,V> withDispatcherConcurrency(int dispatcherConcurrency)
StoreEventSourceConfiguration with the specified dispatcher concurrency
to the configured builder.dispatcherConcurrency - the level of concurrency in the dispatcher for ordered eventspublic CacheConfigurationBuilder<K,V> withEventListenersThreadPool(java.lang.String threadPoolAlias)
ServiceConfiguration for the CacheEventDispatcherFactory specifying
the thread pool alias to use.threadPoolAlias - the thread pool alias to usepublic CacheConfigurationBuilder<K,V> withDiskStoreThreadPool(java.lang.String threadPoolAlias, int concurrency)
ServiceConfiguration for the OffHeapDiskStore.Provider
indicating thread pool alias and write concurrency.threadPoolAlias - the thread pool aliasconcurrency - the write concurrencypublic CacheConfigurationBuilder<K,V> withSizeOfMaxObjectGraph(long size)
DefaultSizeOfEngineConfiguration with the specified object graph maximum size to the configured
builder.
SizeOfEngine is what enables the heap tier to be sized in MemoryUnit.
size - the maximum graph sizepublic CacheConfigurationBuilder<K,V> withSizeOfMaxObjectSize(long size, MemoryUnit unit)
DefaultSizeOfEngineConfiguration with the specified maximum mapping size to the configured
builder.
SizeOfEngine is what enables the heap tier to be sized in MemoryUnit.
size - the maximum mapping sizeunit - the memory unitpublic CacheConfiguration<K,V> build()
Builderbuild in interface Builder<CacheConfiguration<K,V>>