K
- cache key typeV
- cache value typeB
- builder sub-typepublic interface FluentCacheConfigurationBuilder<K,V,B extends FluentCacheConfigurationBuilder<K,V,?>> extends Builder<CacheConfiguration<K,V>>
CacheConfiguration
instances.Modifier and Type | Method and Description |
---|---|
CacheConfiguration<K,V> |
build()
Builds a new
CacheConfiguration . |
default <C extends ServiceConfiguration<?,?>> |
getService(java.lang.Class<C> configurationType)
Return the unique service configuration of the given type.
|
<C extends ServiceConfiguration<?,?>> |
getServices(java.lang.Class<C> configurationType)
Returns all the service configurations of the given type.
|
B |
updateResourcePools(java.util.function.UnaryOperator<ResourcePools> update)
Updates the configured resource pools.
|
<R,C extends ServiceConfiguration<?,R>> |
updateServices(java.lang.Class<C> clazz,
java.util.function.UnaryOperator<R> update)
Updates all service configurations of the given type.
|
B |
withClassLoader(java.lang.ClassLoader classLoader)
Sets the
ClassLoader in the returned builder. |
B |
withDefaultClassLoader()
Removes any previously installed custom class loader
|
B |
withDefaultKeySerializer()
Removes any explicitly configured
Serializer for cache keys. |
B |
withDefaultResilienceStrategy()
Restores configuration of the implementations default resilience strategy.
|
B |
withDefaultValueSerializer()
Removes any explicitly configured
Serializer for cache values. |
B |
withEvictionAdvisor(EvictionAdvisor<? super K,? super V> evictionAdvisor)
Sets the
EvictionAdvisor in the returned builder. |
B |
withExpiry(ExpiryPolicy<? super K,? super V> expiry)
Sets the
ExpiryPolicy configuration in the returned builder. |
B |
withKeyCopier(java.lang.Class<? extends Copier<K>> keyCopierClass)
Adds by-value semantics using the provided
Copier class for the key on heap. |
B |
withKeyCopier(Copier<K> keyCopier)
Adds by-value semantics using the provided
Copier for the key on heap. |
B |
withKeySerializer(java.lang.Class<? extends Serializer<K>> keySerializerClass)
Sets the
Serializer class for cache keys in the returned builder. |
B |
withKeySerializer(Serializer<K> keySerializer)
Sets the
Serializer for cache keys in the returned builder. |
B |
withKeySerializingCopier()
Adds by-value semantics using the cache key serializer for the key on heap.
|
B |
withLoaderWriter(CacheLoaderWriter<K,V> loaderWriter)
Sets the
CacheLoaderWriter in the returned builder. |
B |
withLoaderWriter(java.lang.Class<CacheLoaderWriter<K,V>> loaderWriterClass,
java.lang.Object... arguments)
Sets the
CacheLoaderWriter (using a class and constructor arguments) in the returned builder. |
B |
withoutKeyCopier()
Removes any configured
Copier for keys on heap. |
B |
withoutLoaderWriter()
Removes any configured loader-writer.
|
default B |
withoutServices(java.lang.Class<? extends ServiceConfiguration<?,?>> clazz)
Removes all service configurations of the given type from this configuration.
|
<C extends ServiceConfiguration<?,?>> |
withoutServices(java.lang.Class<C> clazz,
java.util.function.Predicate<? super C> predicate)
Removes all service configurations of the given type that pass the predicate.
|
B |
withoutValueCopier()
Removes any configured
Copier for values on heap. |
B |
withResilienceStrategy(java.lang.Class<? extends ResilienceStrategy> resilienceStrategyClass,
java.lang.Object... arguments)
Sets the
ResilienceStrategy (using a class and constructor arguments) in the returned builder. |
B |
withResilienceStrategy(ResilienceStrategy<K,V> resilienceStrategy)
Sets the
ResilienceStrategy in the returned builder. |
default B |
withResourcePools(Builder<? extends ResourcePools> builder)
Convenience method to set the
ResourcePools through a Builder . |
B |
withResourcePools(ResourcePools resourcePools)
Sets the
ResourcePools in the returned builder. |
default B |
withService(Builder<? extends ServiceConfiguration<?,?>> builder)
Adds a service configuration built by the given builder to this configuration.
|
B |
withService(ServiceConfiguration<?,?> config)
Adds a service configuration to this configuration.
|
B |
withValueCopier(java.lang.Class<? extends Copier<V>> valueCopierClass)
Adds by-value semantics using the provided
Copier class for the value on heap. |
B |
withValueCopier(Copier<V> valueCopier)
Adds by-value semantics using the provided
Copier for the value on heap. |
B |
withValueSerializer(java.lang.Class<? extends Serializer<V>> valueSerializerClass)
Sets the
Serializer class for cache values in the returned builder. |
B |
withValueSerializer(Serializer<V> valueSerializer)
Sets the
Serializer for cache values in the returned builder. |
B |
withValueSerializingCopier()
Adds by-value semantics using the cache value serializer for the value on heap.
|
CacheConfiguration<K,V> build()
CacheConfiguration
.build
in interface Builder<CacheConfiguration<K,V>>
CacheConfiguration
default <C extends ServiceConfiguration<?,?>> C getService(java.lang.Class<C> configurationType) throws java.lang.IllegalArgumentException
If there are multiple configuration instances of this type (or subtypes) then an IllegalArgumentException
will be thrown.
C
- configuration typeconfigurationType
- desired configuration typejava.lang.IllegalArgumentException
- if there are multiple instances of this typegetServices(Class)
,
withService(ServiceConfiguration)
,
withService(Builder)
,
withoutServices(Class)
,
withoutServices(Class, Predicate)
,
updateServices(Class, UnaryOperator)
<C extends ServiceConfiguration<?,?>> java.util.Collection<C> getServices(java.lang.Class<C> configurationType)
C
- configuration typeconfigurationType
- desired configuration typegetService(Class)
,
withService(ServiceConfiguration)
,
withService(Builder)
,
withoutServices(Class)
,
withoutServices(Class, Predicate)
,
updateServices(Class, UnaryOperator)
B withService(ServiceConfiguration<?,?> config)
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)
);
config
- service configurationServiceConfiguration.compatibleWith(ServiceConfiguration)
,
getService(Class)
,
getServices(Class)
,
withService(Builder)
,
withoutServices(Class)
,
withoutServices(Class, Predicate)
,
updateServices(Class, UnaryOperator)
default B withService(Builder<? extends ServiceConfiguration<?,?>> builder)
This will remove any existing configurations that are incompatible with the configuration returned by
builder.build()
.
builder
- service configuration builderwithService(ServiceConfiguration)
,
getService(Class)
,
getServices(Class)
,
withService(ServiceConfiguration)
,
withoutServices(Class)
,
withoutServices(Class, Predicate)
,
updateServices(Class, UnaryOperator)
default B withoutServices(java.lang.Class<? extends ServiceConfiguration<?,?>> clazz)
clazz
- service configuration typegetService(Class)
,
getServices(Class)
,
withService(ServiceConfiguration)
,
withService(Builder)
,
withoutServices(Class, Predicate)
,
updateServices(Class, UnaryOperator)
<C extends ServiceConfiguration<?,?>> B withoutServices(java.lang.Class<C> clazz, java.util.function.Predicate<? super C> predicate)
C
- configuration typeclazz
- service configuration typepredicate
- predicate controlling removalgetService(Class)
,
getServices(Class)
,
withService(ServiceConfiguration)
,
withService(Builder)
,
withoutServices(Class)
,
updateServices(Class, UnaryOperator)
<R,C extends ServiceConfiguration<?,R>> B updateServices(java.lang.Class<C> clazz, java.util.function.UnaryOperator<R> update) throws java.lang.IllegalStateException
For each existing service creation configuration instance that is assignment compatible with clazz
the
following process is performed:
ServiceConfiguration.derive()
method.update
unary operator.ServiceConfiguration.build(Object)
method.clazz
then an
IllegalStateException
will be thrown.R
- configuration detached representation typeC
- service configuration typeclazz
- service configuration concrete typeupdate
- configuration mutation functionjava.lang.IllegalStateException
- if no matching service configurations existgetService(Class)
,
getServices(Class)
,
withService(ServiceConfiguration)
,
withService(Builder)
,
withoutServices(Class)
,
withoutServices(Class, Predicate)
B withEvictionAdvisor(EvictionAdvisor<? super K,? super V> evictionAdvisor)
EvictionAdvisor
in the returned builder.evictionAdvisor
- the eviction advisor to be usedEviction.NO_ADVICE
B withClassLoader(java.lang.ClassLoader classLoader)
ClassLoader
in the returned builder.
The ClassLoader
will be used for resolving all non Ehcache types.
classLoader
- the class loader to usewithDefaultClassLoader()
B withDefaultClassLoader()
withClassLoader(ClassLoader)
B withResourcePools(ResourcePools resourcePools)
ResourcePools
in the returned builder.
ResourcePools
is what determines the tiering of a cache.
resourcePools
- the resource pools to usewithResourcePools(Builder)
,
updateResourcePools(UnaryOperator)
default B withResourcePools(Builder<? extends ResourcePools> builder)
ResourcePools
through a Builder
.builder
- the builder providing the resource poolwithResourcePools(ResourcePools)
,
updateResourcePools(UnaryOperator)
B updateResourcePools(java.util.function.UnaryOperator<ResourcePools> update)
update
- resource pool update operationwithResourcePools(ResourcePools)
,
withResourcePools(Builder)
B withExpiry(ExpiryPolicy<? super K,? super V> expiry)
ExpiryPolicy
configuration in the returned builder.
ExpiryPolicy
is what controls data freshness in a cache.
expiry
- the expiry to useExpiryPolicy.NO_EXPIRY
B withLoaderWriter(CacheLoaderWriter<K,V> loaderWriter)
CacheLoaderWriter
in the returned builder.
Configuration of a CacheLoaderWriter
is what enables cache-through patterns.
loaderWriter
- the loaderwriter to usewithLoaderWriter(Class, Object...)
,
withoutLoaderWriter()
B withLoaderWriter(java.lang.Class<CacheLoaderWriter<K,V>> loaderWriterClass, java.lang.Object... arguments)
CacheLoaderWriter
(using a class and constructor arguments) in the returned builder.
Configuration of a CacheLoaderWriter
is what enables cache-through patterns.
loaderWriterClass
- the loaderwrite classarguments
- optional constructor argumentswithLoaderWriter(CacheLoaderWriter)
,
withoutLoaderWriter()
B withoutLoaderWriter()
withLoaderWriter(CacheLoaderWriter)
,
withLoaderWriter(Class, Object...)
B withResilienceStrategy(ResilienceStrategy<K,V> resilienceStrategy)
ResilienceStrategy
in the returned builder.resilienceStrategy
- the resilience strategy to usewithResilienceStrategy(Class, Object...)
,
withDefaultResilienceStrategy()
B withResilienceStrategy(java.lang.Class<? extends ResilienceStrategy> resilienceStrategyClass, java.lang.Object... arguments)
ResilienceStrategy
(using a class and constructor arguments) in the returned builder.resilienceStrategyClass
- the resilience strategy classarguments
- optional constructor argumentswithResilienceStrategy(ResilienceStrategy)
,
withDefaultResilienceStrategy()
B withDefaultResilienceStrategy()
withResilienceStrategy(ResilienceStrategy)
,
withResilienceStrategy(Class, Object...)
B withKeySerializingCopier()
Copier
s are what enable control of by-reference / by-value semantics for on-heap tier.
withKeyCopier(Copier)
,
withKeyCopier(Class)
,
withoutKeyCopier()
B withValueSerializingCopier()
Copier
s are what enable control of by-reference / by-value semantics for on-heap tier.
withValueCopier(Copier)
,
withValueCopier(Class)
,
withoutValueCopier()
B withKeyCopier(Copier<K> keyCopier)
Copier
for the key on heap.
Copier
s are what enable control of by-reference / by-value semantics for on-heap tier.
keyCopier
- the key copier to usewithKeySerializingCopier()
,
withKeyCopier(Class)
,
withoutKeyCopier()
B withKeyCopier(java.lang.Class<? extends Copier<K>> keyCopierClass)
Copier
class for the key on heap.
Copier
s are what enable control of by-reference / by-value semantics for on-heap tier.
keyCopierClass
- the key copier class to usewithKeySerializingCopier()
,
withKeyCopier(Copier)
,
withoutKeyCopier()
B withoutKeyCopier()
Copier
for keys on heap.withKeySerializingCopier()
,
withKeyCopier(Copier)
,
withKeyCopier(Class)
B withValueCopier(Copier<V> valueCopier)
Copier
for the value on heap.
Copier
s are what enable control of by-reference / by-value semantics for on-heap tier.
valueCopier
- the value copier to usewithValueSerializingCopier()
,
withValueCopier(Class)
,
withoutValueCopier()
B withValueCopier(java.lang.Class<? extends Copier<V>> valueCopierClass)
Copier
class for the value on heap.
Copier
s are what enable control of by-reference / by-value semantics for on-heap tier.
valueCopierClass
- the value copier class to usewithValueSerializingCopier()
,
withValueCopier(Copier)
,
withoutValueCopier()
B withoutValueCopier()
Copier
for values on heap.withValueSerializingCopier()
,
withValueCopier(Copier)
,
withValueCopier(Class)
B withKeySerializer(Serializer<K> keySerializer)
Serializer
for cache keys in the returned builder.
Serializer
s are what enables cache storage beyond the heap tier.
keySerializer
- the key serializer to usewithKeySerializer(Class)
,
withDefaultKeySerializer()
B withKeySerializer(java.lang.Class<? extends Serializer<K>> keySerializerClass)
Serializer
class for cache keys in the returned builder.
Serializer
s are what enables cache storage beyond the heap tier.
keySerializerClass
- the key serializer to usewithKeySerializer(Serializer)
,
withDefaultKeySerializer()
B withDefaultKeySerializer()
Serializer
for cache keys.withKeySerializer(Serializer)
,
withKeySerializer(Class)
B withValueSerializer(Serializer<V> valueSerializer)
Serializer
for cache values in the returned builder.
Serializer
s are what enables cache storage beyond the heap tier.
valueSerializer
- the key serializer to usewithValueSerializer(Class)
,
withDefaultValueSerializer()
B withValueSerializer(java.lang.Class<? extends Serializer<V>> valueSerializerClass)
Serializer
class for cache values in the returned builder.
Serializer
s are what enables cache storage beyond the heap tier.
valueSerializerClass
- the key serializer to usewithValueSerializer(Serializer)
,
withDefaultValueSerializer()
B withDefaultValueSerializer()
Serializer
for cache values.withValueSerializer(Serializer)
,
withValueSerializer(Class)