V - type of the data to store in the cache.public class SelfLoadingCacheBuilder<V> extends Object
Builder
to build default instances of the SelfLoadingCache
interface.| Modifier and Type | Field and Description |
|---|---|
protected CacheProvider<V> |
cacheProvider
The underlying caching system provider.
|
| Modifier | Constructor and Description |
|---|---|
protected |
SelfLoadingCacheBuilder(CacheProvider<V> cacheProvider)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
SelfLoadingCache<V> |
build()
Creates a new default implementation of the
SelfLoadingCache interface. |
void |
setAsyncInsert(boolean asyncInsert)
Sets the given flag to tell if the cache
should insert new keys asynchronously.
|
void |
setAsyncUpdate(boolean asyncUpdate)
Sets the given flag to tell if the cache
should update existing keys asynchronously.
|
void |
setCacheDuration(long cacheDuration)
Sets the given value for the cache duration.
|
void |
setThrowCacheProviderExceptions(boolean throwCacheProviderExceptions)
Sets the given flag to tell if the cache
should propagate cache related exceptions.
|
void |
setTouchDuration(long touchDuration)
Sets the given value for the touch duration.
|
SelfLoadingCacheBuilder |
withAsyncInsert(boolean asyncInsert)
Sets the given flag to tell if the cache
should insert new keys asynchronously and
returns this builder instance.
|
SelfLoadingCacheBuilder |
withAsyncUpdate(boolean asyncUpdate)
Sets the given flag to tell if the cache
should update existing keys asynchronously
and returns this builder instance.
|
SelfLoadingCacheBuilder |
withCacheDuration(long cacheDuration)
Sets the given value for the cache duration
and returns this builder instance.
|
SelfLoadingCacheBuilder |
withThrowCacheProviderExceptions(boolean throwCacheProviderExceptions)
Sets the given flag to tell if the cache
should propagate cache related exceptions
and returns this builder instance.
|
SelfLoadingCacheBuilder |
withTouchDuration(long touchDuration)
Sets the given value for the touch duration
and returns this builder instance.
|
protected final CacheProvider<V> cacheProvider
protected SelfLoadingCacheBuilder(CacheProvider<V> cacheProvider)
This constructor is intended to be used by reflection during de-serialization.
To create a new cache configuration use the factory methods.
cacheProvider - the CacheProvider to be injected into
the SelfLoadingCache created by this builder.RequirementFailure - if the provided CacheProvider is null.public void setCacheDuration(long cacheDuration)
By default this values is set to 1 hour (3600000 ms).
cacheDuration - the cache duration to set.RequirementFailure - if the duration value is less or equal to zero.public SelfLoadingCacheBuilder withCacheDuration(long cacheDuration)
By default this values is set to 1 hour (3600000 ms).
cacheDuration - the cache duration to set.RequirementFailure - if the duration value is less or equal to zero.public void setTouchDuration(long touchDuration)
By default this values is set to 10 minutes (600000 ms).
touchDuration - the touch duration to set.RequirementFailure - if the duration value is less or equal to zero.public SelfLoadingCacheBuilder withTouchDuration(long touchDuration)
By default this values is set to 10 minutes (600000 ms).
touchDuration - the touch duration to set.RequirementFailure - if the duration value is less or equal to zero.public void setAsyncInsert(boolean asyncInsert)
By default this value is false forcing the
requesting thread to load and return the expected data.
asyncInsert - asynchronous insert flag.public SelfLoadingCacheBuilder withAsyncInsert(boolean asyncInsert)
By default this value is false forcing the
requesting thread to load and return the expected data.
asyncInsert - asynchronous insert flag.public void setAsyncUpdate(boolean asyncUpdate)
By default this value is true allowing
the current thread to return immediately the cached value.
asyncUpdate - asynchronous update flag.public SelfLoadingCacheBuilder withAsyncUpdate(boolean asyncUpdate)
By default this value is true allowing
the current thread to return immediately the cached value.
asyncUpdate - asynchronous update flag.public void setThrowCacheProviderExceptions(boolean throwCacheProviderExceptions)
By default this values is false because
an error in the caching system should not cause
a crash in the application.
throwCacheProviderExceptions - cache related propagation flag.public SelfLoadingCacheBuilder withThrowCacheProviderExceptions(boolean throwCacheProviderExceptions)
By default this values is false because
an error in the caching system should not cause
a crash in the application.
throwCacheProviderExceptions - cache related propagation flag.public SelfLoadingCache<V> build()
SelfLoadingCache interface.SelfLoadingCache.Copyright © 2011–2020 Nerd4j. All rights reserved.