Package org.ehcache.config.builders
Class CacheConfigurationBuilder<K,V>
java.lang.Object
org.ehcache.config.builders.CacheConfigurationBuilder<K,V>
- All Implemented Interfaces:
org.ehcache.config.Builder<org.ehcache.config.CacheConfiguration<K,,V>> org.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
public class CacheConfigurationBuilder<K,V>
extends Object
implements org.ehcache.config.FluentCacheConfigurationBuilder<K,V,CacheConfigurationBuilder<K,V>>
The
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.
-
Method Summary
Modifier and TypeMethodDescriptionadd(org.ehcache.config.Builder<? extends org.ehcache.spi.service.ServiceConfiguration<?, ?>> configurationBuilder) Deprecated.add(org.ehcache.spi.service.ServiceConfiguration<?, ?> configuration) Deprecated.in favor ofwithService(ServiceConfiguration)build()Deprecated.in favor ofwithoutServices(ServiceConfiguration.class)<T extends org.ehcache.spi.service.ServiceConfiguration<?,?>>
TgetExistingServiceConfiguration(Class<T> clazz) Deprecated.in favor ofFluentCacheConfigurationBuilder.getService(Class)<T extends org.ehcache.spi.service.ServiceConfiguration<?,?>>
List<T>getExistingServiceConfigurations(Class<T> clazz) Deprecated.in favor ofgetServices(Class)<C extends org.ehcache.spi.service.ServiceConfiguration<?,?>>
Collection<C>getServices(Class<C> configurationType) booleanIndicates whether this builder has configured expiry or not.static <K,V> CacheConfigurationBuilder<K, V> newCacheConfigurationBuilder(Class<K> keyType, Class<V> valueType, org.ehcache.config.Builder<? extends org.ehcache.config.ResourcePools> resourcePoolsBuilder) Creates a new instance ready to produce aCacheConfigurationwith key type<K>and with value type<V>and which will use theconfigured resources, passed as aResourcePoolsBuilder.static <K,V> CacheConfigurationBuilder<K, V> newCacheConfigurationBuilder(Class<K> keyType, Class<V> valueType, org.ehcache.config.ResourcePools resourcePools) Creates a new instance ready to produce aCacheConfigurationwith key type<K>and with value type<V>and which will use theconfigured resources.static <K,V> CacheConfigurationBuilder<K, V> newCacheConfigurationBuilder(org.ehcache.config.CacheConfiguration<K, V> configuration) Creates a new instance ready to produce aCacheConfigurationfunctionally equivalent to the supplied configuration.remove(org.ehcache.spi.service.ServiceConfiguration<?, ?> configuration) Deprecated.in favor ofwithoutServices(Class)orwithoutServices(Class, Predicate)updateResourcePools(UnaryOperator<org.ehcache.config.ResourcePools> update) <R,C extends org.ehcache.spi.service.ServiceConfiguration<?, R>>
CacheConfigurationBuilder<K,V> updateServices(Class<C> clazz, UnaryOperator<R> update) withClassLoader(ClassLoader classLoader) Restores the default disk store thread pool settings.Restores the default dispatcher concurrency.Restores the default event listener thread pool settings.Deprecated.withDiskStoreThreadPool(String threadPoolAlias, int concurrency) Adds aServiceConfigurationfor theOffHeapDiskStore.Providerindicating thread pool alias and write concurrency.withDispatcherConcurrency(int dispatcherConcurrency) AddsStoreEventSourceConfigurationwith the specified dispatcher concurrency to the configured builder.withEventListenersThreadPool(String threadPoolAlias) Adds aServiceConfigurationfor theCacheEventDispatcherFactoryspecifying the thread pool alias to use.withEvictionAdvisor(org.ehcache.config.EvictionAdvisor<? super K, ? super V> evictionAdvisor) withExpiry(org.ehcache.expiry.Expiry<? super K, ? super V> expiry) Deprecated.UsewithExpiry(ExpiryPolicy)insteadwithExpiry(org.ehcache.expiry.ExpiryPolicy<? super K, ? super V> expiry) withKeyCopier(Class<? extends org.ehcache.spi.copy.Copier<K>> keyCopierClass) withKeyCopier(org.ehcache.spi.copy.Copier<K> keyCopier) withKeySerializer(Class<? extends org.ehcache.spi.serialization.Serializer<K>> keySerializerClass) withKeySerializer(org.ehcache.spi.serialization.Serializer<K> keySerializer) withLoaderWriter(Class<org.ehcache.spi.loaderwriter.CacheLoaderWriter<K, V>> loaderWriterClass, Object... arguments) withLoaderWriter(org.ehcache.spi.loaderwriter.CacheLoaderWriter<K, V> loaderWriter) withoutServices(Class<? extends org.ehcache.spi.service.ServiceConfiguration<?, ?>> clazz) <C extends org.ehcache.spi.service.ServiceConfiguration<?,?>>
CacheConfigurationBuilder<K,V> withoutServices(Class<C> clazz, Predicate<? super C> predicate) withResilienceStrategy(Class<? extends org.ehcache.spi.resilience.ResilienceStrategy> resilienceStrategyClass, Object... arguments) withResilienceStrategy(org.ehcache.spi.resilience.ResilienceStrategy<K, V> resilienceStrategy) withResourcePools(org.ehcache.config.ResourcePools resourcePools) withService(org.ehcache.spi.service.ServiceConfiguration<?, ?> config) withSizeOfMaxObjectGraph(long size) Deprecated.withSizeOfMaxObjectSize(long size, org.ehcache.config.units.MemoryUnit unit) Deprecated.withValueCopier(Class<? extends org.ehcache.spi.copy.Copier<V>> valueCopierClass) withValueCopier(org.ehcache.spi.copy.Copier<V> valueCopier) withValueSerializer(Class<? extends org.ehcache.spi.serialization.Serializer<V>> valueSerializerClass) withValueSerializer(org.ehcache.spi.serialization.Serializer<V> valueSerializer) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ehcache.config.FluentCacheConfigurationBuilder
getService, withResourcePools, withService
-
Method Details
-
newCacheConfigurationBuilder
public static <K,V> CacheConfigurationBuilder<K,V> newCacheConfigurationBuilder(Class<K> keyType, Class<V> valueType, org.ehcache.config.ResourcePools resourcePools) Creates a new instance ready to produce aCacheConfigurationwith key type<K>and with value type<V>and which will use theconfigured resources.- Type Parameters:
K- the key typeV- the value type- Parameters:
keyType- the key typevalueType- the value typeresourcePools- the resources to use- Returns:
- a
CacheConfigurationBuilder
-
newCacheConfigurationBuilder
public static <K,V> CacheConfigurationBuilder<K,V> newCacheConfigurationBuilder(Class<K> keyType, Class<V> valueType, org.ehcache.config.Builder<? extends org.ehcache.config.ResourcePools> resourcePoolsBuilder) Creates a new instance ready to produce aCacheConfigurationwith key type<K>and with value type<V>and which will use theconfigured resources, passed as aResourcePoolsBuilder.- Type Parameters:
K- the key typeV- the value type- Parameters:
keyType- the key typevalueType- the value typeresourcePoolsBuilder- the resources to use, as a builder- Returns:
- a
CacheConfigurationBuilder
-
newCacheConfigurationBuilder
public static <K,V> CacheConfigurationBuilder<K,V> newCacheConfigurationBuilder(org.ehcache.config.CacheConfiguration<K, V> configuration) Creates a new instance ready to produce aCacheConfigurationfunctionally equivalent to the supplied configuration.- Type Parameters:
K- the key typeV- the value type- Parameters:
configuration- seed configuration- Returns:
- a
CacheConfigurationBuilder
-
add
@Deprecated public CacheConfigurationBuilder<K,V> add(org.ehcache.spi.service.ServiceConfiguration<?, ?> configuration) Deprecated.in favor ofwithService(ServiceConfiguration)Adds aServiceConfigurationto the returned builder.- Parameters:
configuration- the service configuration to add- Returns:
- a new builder with the added service configuration
-
add
@Deprecated public CacheConfigurationBuilder<K,V> add(org.ehcache.config.Builder<? extends org.ehcache.spi.service.ServiceConfiguration<?, ?>> configurationBuilder) Deprecated.in favor ofFluentCacheConfigurationBuilder.withService(Builder)Convenience method to add aServiceConfigurationthat is produced by aBuilder.- Parameters:
configurationBuilder- the service configuration to add,Builder.build()will be called on it- Returns:
- a new builder with the added service configuration
- See Also:
-
getServices
public <C extends org.ehcache.spi.service.ServiceConfiguration<?,?>> Collection<C> getServices(Class<C> configurationType) throws IllegalArgumentException - Specified by:
getServicesin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>> - Throws:
IllegalArgumentException
-
withService
public CacheConfigurationBuilder<K,V> withService(org.ehcache.spi.service.ServiceConfiguration<?, ?> config) - Specified by:
withServicein interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withoutServices
public CacheConfigurationBuilder<K,V> withoutServices(Class<? extends org.ehcache.spi.service.ServiceConfiguration<?, ?>> clazz) - Specified by:
withoutServicesin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withoutServices
public <C extends org.ehcache.spi.service.ServiceConfiguration<?,?>> CacheConfigurationBuilder<K,V> withoutServices(Class<C> clazz, Predicate<? super C> predicate) - Specified by:
withoutServicesin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
updateServices
public <R,C extends org.ehcache.spi.service.ServiceConfiguration<?, CacheConfigurationBuilder<K,R>> V> updateServices(Class<C> clazz, UnaryOperator<R> update) - Specified by:
updateServicesin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withEvictionAdvisor
public CacheConfigurationBuilder<K,V> withEvictionAdvisor(org.ehcache.config.EvictionAdvisor<? super K, ? super V> evictionAdvisor) - Specified by:
withEvictionAdvisorin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
remove
@Deprecated public CacheConfigurationBuilder<K,V> remove(org.ehcache.spi.service.ServiceConfiguration<?, ?> configuration) Deprecated.in favor ofwithoutServices(Class)orwithoutServices(Class, Predicate)Removes aServiceConfigurationfrom the returned builder.- Parameters:
configuration- the service configuration to remove- Returns:
- a new builder without the specified configuration
-
clearAllServiceConfig
Deprecated.in favor ofwithoutServices(ServiceConfiguration.class)Clears allServiceConfigurations from the returned builder.- Returns:
- a new builder with no service configurations left
-
getExistingServiceConfiguration
@Deprecated public <T extends org.ehcache.spi.service.ServiceConfiguration<?,?>> T getExistingServiceConfiguration(Class<T> clazz) Deprecated.in favor ofFluentCacheConfigurationBuilder.getService(Class)Returns the firstServiceConfigurationwith type matching the class passed in.- Type Parameters:
T- the type of the service configuration- Parameters:
clazz- the service configuration class- Returns:
- a matching service configuration, or
nullif none can be found
-
getExistingServiceConfigurations
@Deprecated public <T extends org.ehcache.spi.service.ServiceConfiguration<?,?>> List<T> getExistingServiceConfigurations(Class<T> clazz) Deprecated.in favor ofgetServices(Class)Returns allServiceConfigurations of type matching the class passed in.- Type Parameters:
T- the type of the service configuration- Parameters:
clazz- the service configuration class- Returns:
- a list with service configurations
-
withClassLoader
- Specified by:
withClassLoaderin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withDefaultClassLoader
- Specified by:
withDefaultClassLoaderin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withResourcePools
public CacheConfigurationBuilder<K,V> withResourcePools(org.ehcache.config.ResourcePools resourcePools) - Specified by:
withResourcePoolsin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
updateResourcePools
public CacheConfigurationBuilder<K,V> updateResourcePools(UnaryOperator<org.ehcache.config.ResourcePools> update) - Specified by:
updateResourcePoolsin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withExpiry
@Deprecated public CacheConfigurationBuilder<K,V> withExpiry(org.ehcache.expiry.Expiry<? super K, ? super V> expiry) Deprecated.UsewithExpiry(ExpiryPolicy)insteadAddsExpiryconfiguration to the returned builder.Expiryis what controls data freshness in a cache.- Parameters:
expiry- the expiry to use- Returns:
- a new builder with the added expiry
-
withExpiry
public CacheConfigurationBuilder<K,V> withExpiry(org.ehcache.expiry.ExpiryPolicy<? super K, ? super V> expiry) - Specified by:
withExpiryin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
hasConfiguredExpiry
public boolean hasConfiguredExpiry()Indicates whether this builder has configured expiry or not.- Returns:
trueif expiry configured,falseotherwise
-
withLoaderWriter
public CacheConfigurationBuilder<K,V> withLoaderWriter(org.ehcache.spi.loaderwriter.CacheLoaderWriter<K, V> loaderWriter) - Specified by:
withLoaderWriterin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withLoaderWriter
public CacheConfigurationBuilder<K,V> withLoaderWriter(Class<org.ehcache.spi.loaderwriter.CacheLoaderWriter<K, V>> loaderWriterClass, Object... arguments) - Specified by:
withLoaderWriterin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withoutLoaderWriter
- Specified by:
withoutLoaderWriterin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withResilienceStrategy
public CacheConfigurationBuilder<K,V> withResilienceStrategy(org.ehcache.spi.resilience.ResilienceStrategy<K, V> resilienceStrategy) - Specified by:
withResilienceStrategyin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withResilienceStrategy
public CacheConfigurationBuilder<K,V> withResilienceStrategy(Class<? extends org.ehcache.spi.resilience.ResilienceStrategy> resilienceStrategyClass, Object... arguments) - Specified by:
withResilienceStrategyin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withDefaultResilienceStrategy
- Specified by:
withDefaultResilienceStrategyin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withKeySerializingCopier
- Specified by:
withKeySerializingCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withValueSerializingCopier
- Specified by:
withValueSerializingCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withKeyCopier
- Specified by:
withKeyCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withKeyCopier
public CacheConfigurationBuilder<K,V> withKeyCopier(Class<? extends org.ehcache.spi.copy.Copier<K>> keyCopierClass) - Specified by:
withKeyCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withoutKeyCopier
- Specified by:
withoutKeyCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withValueCopier
- Specified by:
withValueCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withValueCopier
public CacheConfigurationBuilder<K,V> withValueCopier(Class<? extends org.ehcache.spi.copy.Copier<V>> valueCopierClass) - Specified by:
withValueCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withoutValueCopier
- Specified by:
withoutValueCopierin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withKeySerializer
public CacheConfigurationBuilder<K,V> withKeySerializer(org.ehcache.spi.serialization.Serializer<K> keySerializer) - Specified by:
withKeySerializerin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withKeySerializer
public CacheConfigurationBuilder<K,V> withKeySerializer(Class<? extends org.ehcache.spi.serialization.Serializer<K>> keySerializerClass) - Specified by:
withKeySerializerin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withDefaultKeySerializer
- Specified by:
withDefaultKeySerializerin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withValueSerializer
public CacheConfigurationBuilder<K,V> withValueSerializer(org.ehcache.spi.serialization.Serializer<V> valueSerializer) - Specified by:
withValueSerializerin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withValueSerializer
public CacheConfigurationBuilder<K,V> withValueSerializer(Class<? extends org.ehcache.spi.serialization.Serializer<V>> valueSerializerClass) - Specified by:
withValueSerializerin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withDefaultValueSerializer
- Specified by:
withDefaultValueSerializerin interfaceorg.ehcache.config.FluentCacheConfigurationBuilder<K,V, CacheConfigurationBuilder<K, V>>
-
withDispatcherConcurrency
AddsStoreEventSourceConfigurationwith the specified dispatcher concurrency to the configured builder.- Parameters:
dispatcherConcurrency- the level of concurrency in the dispatcher for ordered events- Returns:
- a new builder with the added configuration
- See Also:
-
withDefaultDispatcherConcurrency
Restores the default dispatcher concurrency.- Returns:
- a new builder with the default dispatcher concurrency
- See Also:
-
withEventListenersThreadPool
Adds aServiceConfigurationfor theCacheEventDispatcherFactoryspecifying the thread pool alias to use.- Parameters:
threadPoolAlias- the thread pool alias to use- Returns:
- a new builder with the added configuration
- See Also:
-
withDefaultEventListenersThreadPool
Restores the default event listener thread pool settings.- Returns:
- a new builder with the default event listener thread pool settings
- See Also:
-
withDiskStoreThreadPool
public CacheConfigurationBuilder<K,V> withDiskStoreThreadPool(String threadPoolAlias, int concurrency) Adds aServiceConfigurationfor theOffHeapDiskStore.Providerindicating thread pool alias and write concurrency.- Parameters:
threadPoolAlias- the thread pool aliasconcurrency- the write concurrency- Returns:
- a new builder with the added configuration
- See Also:
-
withDefaultDiskStoreThreadPool
Restores the default disk store thread pool settings.- Returns:
- a new builder with the default disk store thread pool settings
- See Also:
-
withSizeOfMaxObjectGraph
Deprecated.Adds or updates theDefaultSizeOfEngineConfigurationwith the specified object graph maximum size to the configured builder.SizeOfEngineis what enables the heap tier to be sized inMemoryUnit.- Parameters:
size- the maximum graph size- Returns:
- a new builder with the added / updated configuration
- See Also:
-
withSizeOfMaxObjectSize
@Deprecated public CacheConfigurationBuilder<K,V> withSizeOfMaxObjectSize(long size, org.ehcache.config.units.MemoryUnit unit) Deprecated.Adds or updates theDefaultSizeOfEngineConfigurationwith the specified maximum mapping size to the configured builder.SizeOfEngineis what enables the heap tier to be sized inMemoryUnit.- Parameters:
size- the maximum mapping sizeunit- the memory unit- Returns:
- a new builder with the added / updated configuration
- See Also:
-
withDefaultSizeOfSettings
Deprecated.Restores the default size-of settings.- Returns:
- a new builder with the default size-of settings
- See Also:
-
build
-
FluentCacheConfigurationBuilder.withService(Builder)