public class CacheConfig extends Object
SelfLoadingCache.| Modifier and Type | Field and Description |
|---|---|
protected static long |
DEFAULT_CACHE_DURATION
Default duration of a cache entry in milliseconds (60 minutes).
|
protected static long |
DEFAULT_TOUCH_DURATION
Default duration in milliseconds used by the method
CacheProvider.touch(CacheKey,long) (10 minutes). |
protected static boolean |
disabledAll
Tells if all the
SelfLoadingCaches in the system are disabled. |
| Modifier | Constructor and Description |
|---|---|
protected |
CacheConfig()
Default constructor.
|
protected |
CacheConfig(long cacheDuration,
long touchDuration,
boolean asyncInsert,
boolean asyncUpdate,
boolean throwCacheProviderExceptions)
Constructor with parameters.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
disableAll(boolean disable)
Invoking this method with
true will disable all SelfLoadingCache
instances in the system. |
boolean |
equals(Object other) |
long |
getCacheDuration()
Returns the duration of a cache entry in milliseconds.
|
static CacheConfig |
getDefault()
Creates a new
CacheConfig with the following
default values:
getCacheDuration() = DEFAULT_CACHE_DURATION
getTouchDuration() = DEFAULT_TOUCH_DURATION
isAsyncInsert() = false
isAsyncUpdate() = true
isThrowCacheProviderExceptions() = false
|
long |
getTouchDuration()
Returns the number of milliseconds to defer
a cache entry expiration to, during update.
|
int |
hashCode() |
boolean |
isAsyncInsert()
Tells if the insert of a new entry in the cache
should be done asynchronously.
|
boolean |
isAsyncUpdate()
Tells if the update of an existing entry in the cache
should be done asynchronously.
|
boolean |
isThrowCacheProviderExceptions()
Tells if any exception generated by the
CacheProvider
should be propagated outside the SelfLoadingCache. |
static CacheConfig |
of(boolean asyncInsert,
boolean asyncUpdate,
boolean throwCacheProviderExceptions)
Creates a new
CacheConfig with the default cache and touch
durations and given values. |
static CacheConfig |
of(long cacheDuration,
long touchDuration,
boolean asyncInsert,
boolean asyncUpdate,
boolean throwCacheProviderExceptions)
Creates a new
CacheConfig with the given values. |
String |
toString() |
protected static final long DEFAULT_CACHE_DURATION
protected static final long DEFAULT_TOUCH_DURATION
CacheProvider.touch(CacheKey,long) (10 minutes).protected static boolean disabledAll
SelfLoadingCaches in the system are disabled.
If this flag is set to true all the caching will be skipped
and all data will be loaded on each request.
This option should be used to debugging purposes only, using this option in production can be very dangerous.
protected CacheConfig()
This constructor is intended to be used by reflection during de-serialization.
To create a new cache configuration use the factory methods.
protected CacheConfig(long cacheDuration,
long touchDuration,
boolean asyncInsert,
boolean asyncUpdate,
boolean throwCacheProviderExceptions)
This constructor is intended to be used by extending classes only.
To create a new cache configuration use the factory methods.
cacheDuration - duration of the cache entry after put.touchDuration - duration of the cache entry after touch.asyncInsert - tells if the insert should be done asynchronously.asyncUpdate - tells if the update should be done asynchronously.throwCacheProviderExceptions - tells if any exception generated by
the CacheProvider should be
thrown.public static CacheConfig getDefault()
CacheConfig with the following
default values:
CacheConfig with default values.public static CacheConfig of(boolean asyncInsert, boolean asyncUpdate, boolean throwCacheProviderExceptions)
CacheConfig with the default cache and touch
durations and given values.asyncInsert - tells if the insert should be done asynchronously.asyncUpdate - tells if the update should be done asynchronously.throwCacheProviderExceptions - tells if any exception generated by
the CacheProvider should be
thrown.CacheConfig with the given values.public static CacheConfig of(long cacheDuration, long touchDuration, boolean asyncInsert, boolean asyncUpdate, boolean throwCacheProviderExceptions)
CacheConfig with the given values.cacheDuration - duration of the cache entry after put.touchDuration - duration of the cache entry after touch.asyncInsert - tells if the insert should be done asynchronously.asyncUpdate - tells if the update should be done asynchronously.throwCacheProviderExceptions - tells if any exception generated by
the CacheProvider should be
thrown.CacheConfig with the given values.public static void disableAll(boolean disable)
true will disable all SelfLoadingCache
instances in the system. All the caching will be skipped and all data will be
loaded from the DataProvider on each request.
This option should be used to debugging purposes only, using this option in production can be very dangerous.
Invoking this method with false will restore the caching process.
disable - tells if all SelfLoadingCache instances need to stop
all caching operations.public long getCacheDuration()
public long getTouchDuration()
public boolean isAsyncInsert()
true if the insert of a new entry
in the cache should be done asynchronously.public boolean isAsyncUpdate()
true if the insert of an existing entry
in the cache should be done asynchronously.public boolean isThrowCacheProviderExceptions()
CacheProvider
should be propagated outside the SelfLoadingCache.
By default this values is false because an error
in the caching system should not cause a crash in the
application.true if any exception generated by
the CacheProvider should be thrown.Copyright © 2011–2020 Nerd4j. All rights reserved.