Interface FluentCacheConfigurationBuilder<K,V,B extends FluentCacheConfigurationBuilder<K,V,?>>
- Type Parameters:
K- cache key typeV- cache value typeB- builder sub-type
- All Superinterfaces:
Builder<CacheConfiguration<K,V>>
CacheConfiguration instances.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newCacheConfiguration.default <C extends ServiceConfiguration<?,?>>
CgetService(Class<C> configurationType) Return the unique service configuration of the given type.<C extends ServiceConfiguration<?,?>>
Collection<C>getServices(Class<C> configurationType) Returns all the service configurations of the given type.Updates the configured resource pools.<R,C extends ServiceConfiguration<?, R>>
BupdateServices(Class<C> clazz, UnaryOperator<R> update) Updates all service configurations of the given type.withClassLoader(ClassLoader classLoader) Sets theClassLoaderin the returned builder.Removes any previously installed custom class loaderRemoves any explicitly configuredSerializerfor cache keys.Restores configuration of the implementations default resilience strategy.Removes any explicitly configuredSerializerfor cache values.withEvictionAdvisor(EvictionAdvisor<? super K, ? super V> evictionAdvisor) Sets theEvictionAdvisorin the returned builder.withExpiry(ExpiryPolicy<? super K, ? super V> expiry) Sets theExpiryPolicyconfiguration in the returned builder.withKeyCopier(Class<? extends Copier<K>> keyCopierClass) Adds by-value semantics using the providedCopierclass for the key on heap.withKeyCopier(Copier<K> keyCopier) Adds by-value semantics using the providedCopierfor the key on heap.withKeySerializer(Class<? extends Serializer<K>> keySerializerClass) Sets theSerializerclass for cache keys in the returned builder.withKeySerializer(Serializer<K> keySerializer) Sets theSerializerfor cache keys in the returned builder.Adds by-value semantics using the cache key serializer for the key on heap.withLoaderWriter(Class<CacheLoaderWriter<K, V>> loaderWriterClass, Object... arguments) Sets theCacheLoaderWriter(using a class and constructor arguments) in the returned builder.withLoaderWriter(CacheLoaderWriter<K, V> loaderWriter) Sets theCacheLoaderWriterin the returned builder.Removes any configuredCopierfor keys on heap.Removes any configured loader-writer.default BwithoutServices(Class<? extends ServiceConfiguration<?, ?>> clazz) Removes all service configurations of the given type from this configuration.<C extends ServiceConfiguration<?,?>>
BwithoutServices(Class<C> clazz, Predicate<? super C> predicate) Removes all service configurations of the given type that pass the predicate.Removes any configuredCopierfor values on heap.withResilienceStrategy(Class<? extends ResilienceStrategy> resilienceStrategyClass, Object... arguments) Sets theResilienceStrategy(using a class and constructor arguments) in the returned builder.withResilienceStrategy(ResilienceStrategy<K, V> resilienceStrategy) Sets theResilienceStrategyin the returned builder.default BwithResourcePools(Builder<? extends ResourcePools> builder) Convenience method to set theResourcePoolsthrough aBuilder.withResourcePools(ResourcePools resourcePools) Sets theResourcePoolsin the returned builder.default BwithService(Builder<? extends ServiceConfiguration<?, ?>> builder) Adds a service configuration built by the given builder to this configuration.withService(ServiceConfiguration<?, ?> config) Adds a service configuration to this configuration.withValueCopier(Class<? extends Copier<V>> valueCopierClass) Adds by-value semantics using the providedCopierclass for the value on heap.withValueCopier(Copier<V> valueCopier) Adds by-value semantics using the providedCopierfor the value on heap.withValueSerializer(Class<? extends Serializer<V>> valueSerializerClass) Sets theSerializerclass for cache values in the returned builder.withValueSerializer(Serializer<V> valueSerializer) Sets theSerializerfor cache values in the returned builder.Adds by-value semantics using the cache value serializer for the value on heap.
-
Method Details
-
build
CacheConfiguration<K,V> build()Builds a newCacheConfiguration. -
getService
default <C extends ServiceConfiguration<?,?>> C getService(Class<C> configurationType) throws IllegalArgumentException Return the unique service configuration of the given type.If there are multiple configuration instances of this type (or subtypes) then an
IllegalArgumentExceptionwill be thrown.- Type Parameters:
C- configuration type- Parameters:
configurationType- desired configuration type- Returns:
- the service configuration of the given type; @{code null} if there is no service configuration of the given type
- Throws:
IllegalArgumentException- if there are multiple instances of this type- See Also:
-
getServices
Returns all the service configurations of the given type.- Type Parameters:
C- configuration type- Parameters:
configurationType- desired configuration type- Returns:
- all services of this type
- See Also:
-
withService
Adds a service configuration to this configuration.This will remove any existing service configurations that are incompatible with the supplied one. This removal is equivalent to the following:
configurations.removeIf( existing -> !config.compatibleWith(existing) || !existing.compatibleWith(config) );- Parameters:
config- service configuration- Returns:
- an updated builder
- See Also:
-
withService
Adds a service configuration built by the given builder to this configuration.This will remove any existing configurations that are incompatible with the configuration returned by
builder.build().- Parameters:
builder- service configuration builder- Returns:
- an updated builder
- See Also:
-
withoutServices
Removes all service configurations of the given type from this configuration.- Parameters:
clazz- service configuration type- Returns:
- an updated builder
- See Also:
-
withoutServices
<C extends ServiceConfiguration<?,?>> B withoutServices(Class<C> clazz, Predicate<? super C> predicate) Removes all service configurations of the given type that pass the predicate.- Type Parameters:
C- configuration type- Parameters:
clazz- service configuration typepredicate- predicate controlling removal- Returns:
- an updated builder
- See Also:
-
updateServices
<R,C extends ServiceConfiguration<?, B updateServicesR>> (Class<C> clazz, UnaryOperator<R> update) throws IllegalStateException Updates all service configurations of the given type.For each existing service creation configuration instance that is assignment compatible with
clazzthe following process is performed:- The configuration is converted to its detached representations using the
ServiceConfiguration.derive()method. - The detached representation is transformed using the
updateunary operator. - A new configuration is generated by passing the transformed detached representation to the existing
configurations
ServiceConfiguration.build(Object)method. - The new configuration is added to the builders service configuration set.
clazzthen anIllegalStateExceptionwill be thrown.- Type Parameters:
R- configuration detached representation typeC- service configuration type- Parameters:
clazz- service configuration concrete typeupdate- configuration mutation function- Returns:
- an updated builder
- Throws:
IllegalStateException- if no matching service configurations exist- See Also:
- The configuration is converted to its detached representations using the
-
withEvictionAdvisor
Sets theEvictionAdvisorin the returned builder.- Parameters:
evictionAdvisor- the eviction advisor to be used- Returns:
- a new builder with the added eviction advisor
- See Also:
-
Eviction.NO_ADVICE
-
withClassLoader
Sets theClassLoaderin the returned builder.The
ClassLoaderwill be used for resolving all non Ehcache types.- Parameters:
classLoader- the class loader to use- Returns:
- a new builder with the added class loader
- See Also:
-
withDefaultClassLoader
B withDefaultClassLoader()Removes any previously installed custom class loader- Returns:
- a new build using the default class loader
- See Also:
-
withResourcePools
Sets theResourcePoolsin the returned builder.ResourcePoolsis what determines the tiering of a cache.- Parameters:
resourcePools- the resource pools to use- Returns:
- a new builder with the added resource pools
- See Also:
-
withResourcePools
Convenience method to set theResourcePoolsthrough aBuilder.- Parameters:
builder- the builder providing the resource pool- Returns:
- a new builder with the added resource pools
- See Also:
-
updateResourcePools
Updates the configured resource pools.- Parameters:
update- resource pool update operation- Returns:
- a new build with updated resource pools
- See Also:
-
withExpiry
Sets theExpiryPolicyconfiguration in the returned builder.ExpiryPolicyis what controls data freshness in a cache.- Parameters:
expiry- the expiry to use- Returns:
- a new builder with the added expiry
- See Also:
-
withLoaderWriter
Sets theCacheLoaderWriterin the returned builder.Configuration of a
CacheLoaderWriteris what enables cache-through patterns.- Parameters:
loaderWriter- the loaderwriter to use- Returns:
- a new builder with the added loaderwriter configuration
- See Also:
-
withLoaderWriter
Sets theCacheLoaderWriter(using a class and constructor arguments) in the returned builder.Configuration of a
CacheLoaderWriteris what enables cache-through patterns.- Parameters:
loaderWriterClass- the loaderwrite classarguments- optional constructor arguments- Returns:
- a new builder with the added loaderwriter configuration
- See Also:
-
withoutLoaderWriter
B withoutLoaderWriter()Removes any configured loader-writer.- Returns:
- a new build with no configured loader-writer
- See Also:
-
withResilienceStrategy
Sets theResilienceStrategyin the returned builder.- Parameters:
resilienceStrategy- the resilience strategy to use- Returns:
- a new builder with the added resilience strategy configuration
- See Also:
-
withResilienceStrategy
B withResilienceStrategy(Class<? extends ResilienceStrategy> resilienceStrategyClass, Object... arguments) Sets theResilienceStrategy(using a class and constructor arguments) in the returned builder.- Parameters:
resilienceStrategyClass- the resilience strategy classarguments- optional constructor arguments- Returns:
- a new builder with the added resilience strategy configuration
- See Also:
-
withDefaultResilienceStrategy
B withDefaultResilienceStrategy()Restores configuration of the implementations default resilience strategy.- Returns:
- a new builder using the default resilience strategy
- See Also:
-
withKeySerializingCopier
B withKeySerializingCopier()Adds by-value semantics using the cache key serializer for the key on heap.Copiers are what enable control of by-reference / by-value semantics for on-heap tier.- Returns:
- a new builder with the added key copier
- See Also:
-
withValueSerializingCopier
B withValueSerializingCopier()Adds by-value semantics using the cache value serializer for the value on heap.Copiers are what enable control of by-reference / by-value semantics for on-heap tier.- Returns:
- a new builder with the added value copier
- See Also:
-
withKeyCopier
Adds by-value semantics using the providedCopierfor the key on heap.Copiers are what enable control of by-reference / by-value semantics for on-heap tier.- Parameters:
keyCopier- the key copier to use- Returns:
- a new builder with the added key copier
- See Also:
-
withKeyCopier
Adds by-value semantics using the providedCopierclass for the key on heap.Copiers are what enable control of by-reference / by-value semantics for on-heap tier.- Parameters:
keyCopierClass- the key copier class to use- Returns:
- a new builder with the added key copier
- See Also:
-
withoutKeyCopier
B withoutKeyCopier()Removes any configuredCopierfor keys on heap.- Returns:
- a new builder without a key copier
- See Also:
-
withValueCopier
Adds by-value semantics using the providedCopierfor the value on heap.Copiers are what enable control of by-reference / by-value semantics for on-heap tier.- Parameters:
valueCopier- the value copier to use- Returns:
- a new builder with the added value copier
- See Also:
-
withValueCopier
Adds by-value semantics using the providedCopierclass for the value on heap.Copiers are what enable control of by-reference / by-value semantics for on-heap tier.- Parameters:
valueCopierClass- the value copier class to use- Returns:
- a new builder with the added value copier
- See Also:
-
withoutValueCopier
B withoutValueCopier()Removes any configuredCopierfor values on heap.- Returns:
- a new builder without a value copier
- See Also:
-
withKeySerializer
Sets theSerializerfor cache keys in the returned builder.Serializers are what enables cache storage beyond the heap tier.- Parameters:
keySerializer- the key serializer to use- Returns:
- a new builder with the added key serializer
- See Also:
-
withKeySerializer
Sets theSerializerclass for cache keys in the returned builder.Serializers are what enables cache storage beyond the heap tier.- Parameters:
keySerializerClass- the key serializer to use- Returns:
- a new builder with the added key serializer
- See Also:
-
withDefaultKeySerializer
B withDefaultKeySerializer()Removes any explicitly configuredSerializerfor cache keys.- Returns:
- a new builder with no configured key serializer
- See Also:
-
withValueSerializer
Sets theSerializerfor cache values in the returned builder.Serializers are what enables cache storage beyond the heap tier.- Parameters:
valueSerializer- the key serializer to use- Returns:
- a new builder with the added value serializer
- See Also:
-
withValueSerializer
Sets theSerializerclass for cache values in the returned builder.Serializers are what enables cache storage beyond the heap tier.- Parameters:
valueSerializerClass- the key serializer to use- Returns:
- a new builder with the added value serializer
- See Also:
-
withDefaultValueSerializer
B withDefaultValueSerializer()Removes any explicitly configuredSerializerfor cache values.- Returns:
- a new builder with no configured value serializer
- See Also:
-