public class DefaultLRUCachingMapConfiguration extends Object implements LRUCachingMapConfiguration
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_CLEANUP_INTERVAL
Default cleanup interval is 15 minuttes.
|
static long |
DEFAULT_EXPIRE_TIME
Default expiretime is 10 hours.
|
static long |
DEFAULT_EXTEND_TIME
Default extend time is 1 hour.
|
static int |
DEFAULT_MAX_EXTEND_COUNT
Default max extend count is 5
|
static int |
DEFAULT_MAX_SIZE
Default max size is 10000.
|
static boolean |
DEFAULT_PERSISTED_VALUES_IN_MEMORY
Default value if persisted values should be stored in memory as well -
true . |
Constructor and Description |
---|
DefaultLRUCachingMapConfiguration()
Default constructor using default parameters as constructor parameters.
|
DefaultLRUCachingMapConfiguration(long expireTime,
long extendTime,
int maxExtendCount,
int maxSize,
long cleanupInterval,
boolean persistedValuesInMemory)
Constructor.
|
DefaultLRUCachingMapConfiguration(TimeSpan expireTime,
TimeSpan extendTime,
int maxExtendCount,
int maxSize,
TimeSpan cleanupInterval,
boolean persistedValuesInMemory)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
getCleanupIntervalTime()
How long interval between cleanup is performed by an internal thread.
|
long |
getExpireTime()
How many milliseconds a key may be in the cache per default, before it is removed from cache.
|
long |
getExtendTime()
When a Key is retrieved from the class via get(K key) the Key/Value pair can has it expire time extended.
|
int |
getMaxExtendCount()
How many times an Key/Value pair is allowed to be extended in expiretime.
|
int |
getMaxSize()
How many keys is maximum allowed in the class, if exceeded the oldest entries is removed until below maxSize.
|
boolean |
isPersistedValuesInMemory()
If the values for persisted LRUCachingMaps should be held in memory or not.
If false the values for persisted storage will have to retrieved from persisted storage for each get, if true all values is held in memory as well, this will have an effect on your memory usage. |
DefaultLRUCachingMapConfiguration |
noAutoCleanup()
Sets the cleanupIntervalTime to zero.
Meaning during the construction of a LRUCachingMap, no cleanup timer thread is created. |
DefaultLRUCachingMapConfiguration |
noExtendTime()
Sets the extendTime to zero.
|
DefaultLRUCachingMapConfiguration |
noMaxExtendCount()
Sets the maxExtendCount to zero.
|
static DefaultLRUCachingMapConfiguration |
ONE_DAY()
Creates a new instance of DefaultLRUCachingMapConfiguration where the parameters is:
expireTime : 1 day
extendTime : 1 hour
maxExtendCount : 5
maxSize : 10000
cleanupInterval : 15 minutes
persistedValuesInMemory : false
|
static DefaultLRUCachingMapConfiguration |
ONE_HOUR()
Creates a new instance of DefaultLRUCachingMapConfiguration where the parameters is:
expireTime : 1 hour
extendTime : 5 minutes
maxExtendCount : 5
maxSize : 10000
cleanupInterval : 5 minutes
persistedValuesInMemory : true
|
static DefaultLRUCachingMapConfiguration |
ONE_MINUTE()
Creates a new instance of DefaultLRUCachingMapConfiguration where the parameters is:
expireTime : 1 minute
extendTime : 0
maxExtendCount : 5
maxSize : 1000
cleanupInterval : 1 minute
persistedValuesInMemory : true
|
static DefaultLRUCachingMapConfiguration |
ONE_WEEK()
Creates a new instance of DefaultLRUCachingMapConfiguration where the parameters is:
expireTime : 7 days
extendTime : 6 hours
maxExtendCount : 5
maxSize : 10000
cleanupInterval : 1 hour
persistedValuesInMemory : false
|
DefaultLRUCachingMapConfiguration |
setCleanupIntervalTime(long cleanupIntervalTime)
Setting this value AFTER the LRUCachingMap has been constructed has NO effect !!!!.
|
DefaultLRUCachingMapConfiguration |
setCleanupIntervalTimeSpan(TimeSpan cleanupIntervalTimeSpan)
Sets the cleanupIntervalTime using a TimeSpan.
|
DefaultLRUCachingMapConfiguration |
setExpireTime(long expireTime)
Set the expireTime for a key in milliseconds.
|
DefaultLRUCachingMapConfiguration |
setExpireTimeSpan(TimeSpan expireTimeSpan)
Sets the expireTime using a TimeSpan.
|
DefaultLRUCachingMapConfiguration |
setExtendTime(long extendTime)
How many milliseconds a "key"'s expire time is extended in milliseconds everytime is it "get" from a "LRUCachingMap".
|
DefaultLRUCachingMapConfiguration |
setExtendTimeSpan(TimeSpan extendTimeSpan)
Sets the extendTime using a TimeSpan.
|
DefaultLRUCachingMapConfiguration |
setMaxExtendCount(int maxExtendCount)
How many times a "key"'s expire time is allowed to be extended.
|
DefaultLRUCachingMapConfiguration |
setMaxSize(int maxSize)
The maximum number of elements in a LRUCachingMap before "cleanup" is performed to reduce the map size.
|
LRUCachingMapConfiguration |
setPersistedValuesInMemory(boolean persistedValuesInMemory)
If the values for persisted LRUCachingMaps should be held in memory or not.
If false the values for persisted storage will have to retrieved from persisted storage for each get, if true all values is held in memory as well, this will have an effect on your memory usage. |
static DefaultLRUCachingMapConfiguration |
TEN_MINUTES()
Creates a new instance of DefaultLRUCachingMapConfiguration where the parameters is:
expireTime : 10 minutes
extendTime : 1 minute
maxExtendCount : 5
maxSize : 5000
cleanupInterval : 2 minutes
persistedValuesInMemory : true
|
public static final long DEFAULT_EXPIRE_TIME
public static final long DEFAULT_EXTEND_TIME
public static final int DEFAULT_MAX_EXTEND_COUNT
public static final long DEFAULT_CLEANUP_INTERVAL
public static final int DEFAULT_MAX_SIZE
public static final boolean DEFAULT_PERSISTED_VALUES_IN_MEMORY
true
.public DefaultLRUCachingMapConfiguration()
public DefaultLRUCachingMapConfiguration(TimeSpan expireTime, TimeSpan extendTime, int maxExtendCount, int maxSize, TimeSpan cleanupInterval, boolean persistedValuesInMemory)
expireTime
- How many milliseconds a key may be in the cache per default, before it is removed from cache. Must be be greather the zero.extendTime
- How How many times an Key/Value pair is allowed to be extended in expiretime/TTL. If zero than no extension. If less than zero, not limit to the extension count.maxExtendCount
- How many times a a Keys expire time can be extended when get(K key) is called. If zero or less, than no extension of expire time is performed.maxSize
- How many keys is maximum allowed in the class, if exceeded the oldest entries is removed until below maxSize. Must be be greather the zero.cleanupInterval
- How many milliseconds between automatic cleanup of the cache, performed by an internal thread. If zero or less no cleanup thread is created, and you must handle this manually.persistedValuesInMemory
- if persisted values should also be stored in memory for quick access.IllegalArgumentException
- if any of the parameters fails validation.NullPointerException
- if any of the timeunit parameters is null
.public DefaultLRUCachingMapConfiguration(long expireTime, long extendTime, int maxExtendCount, int maxSize, long cleanupInterval, boolean persistedValuesInMemory) throws IllegalArgumentException, NullPointerException
expireTime
- How many milliseconds a key may be in the cache per default, before it is removed from cache. Must be be greather the zero.extendTime
- How How many times an Key/Value pair is allowed to be extended in expiretime/TTL. If zero than no extension. If less than zero, not limit to the extension count.maxExtendCount
- How many times a a Keys expire time can be extended when get(K key) is called. If zero or less, than no extension of expire time is performed.maxSize
- How many keys is maximum allowed in the class, if exceeded the oldest entries is removed until below maxSize. Must be be greather the zero.cleanupInterval
- how many milliseconds between automatic cleanup of the cache, performed by an internal thread. If zero or less no cleanup thread is created, and you must handle this manually.persistedValuesInMemory
- if persisted values should also be stored in memory for quick access.IllegalArgumentException
- if any of the parameters fails validation.NullPointerException
public static final DefaultLRUCachingMapConfiguration ONE_WEEK()
public static final DefaultLRUCachingMapConfiguration ONE_DAY()
public static final DefaultLRUCachingMapConfiguration ONE_HOUR()
public static final DefaultLRUCachingMapConfiguration TEN_MINUTES()
public static final DefaultLRUCachingMapConfiguration ONE_MINUTE()
public long getCleanupIntervalTime()
LRUCachingMapConfiguration
getCleanupIntervalTime
in interface LRUCachingMapConfiguration
public long getExpireTime()
LRUCachingMapConfiguration
getExpireTime
in interface LRUCachingMapConfiguration
public long getExtendTime()
LRUCachingMapConfiguration
getExtendTime
in interface LRUCachingMapConfiguration
public int getMaxExtendCount()
LRUCachingMapConfiguration
getMaxExtendCount
in interface LRUCachingMapConfiguration
public int getMaxSize()
LRUCachingMapConfiguration
getMaxSize
in interface LRUCachingMapConfiguration
public DefaultLRUCachingMapConfiguration setCleanupIntervalTime(long cleanupIntervalTime)
setCleanupIntervalTime
in interface LRUCachingMapConfiguration
cleanupIntervalTime
- the cleanup interval in milliseconds, if ">0" an internal timer thread will handle this, otherwise you must handle this yourself.LRUCachingMap.cleanup()
is called.CleanupTimerRunnable
public DefaultLRUCachingMapConfiguration setExpireTime(long expireTime) throws IllegalArgumentException
LRUCachingMapConfiguration
setExpireTime
in interface LRUCachingMapConfiguration
expireTime
- the expire time in milliseconds.IllegalArgumentException
- if expireTime is less than one.public DefaultLRUCachingMapConfiguration setExtendTime(long extendTime)
LRUCachingMapConfiguration
setExtendTime
in interface LRUCachingMapConfiguration
extendTime
- how many milliseconds a key's expire time is extended in milliseconds everytime is it "get" from a "LRUCachingMap".LRUCachingMap.get(Object)
public DefaultLRUCachingMapConfiguration setMaxExtendCount(int maxExtendCount)
LRUCachingMapConfiguration
setMaxExtendCount
in interface LRUCachingMapConfiguration
maxExtendCount
- How many times a "key"'s expire time is allowed to be extended, if "<=0" than no expiration time extension is allowed.public DefaultLRUCachingMapConfiguration setMaxSize(int maxSize)
LRUCachingMapConfiguration
setMaxSize
in interface LRUCachingMapConfiguration
maxSize
- the maximum number of keys allowed in the cache.LRUCachingMap.cleanup()
,
LRUCachingMap.getNextToExpire()
public boolean isPersistedValuesInMemory()
LRUCachingMapConfiguration
false
the values for persisted storage will have to retrieved from persisted storage for each get, if true
all values is held in memory as well, this will have an effect on your memory usage.
Only applies for LRUCachingMap implementation which has persisted storage.isPersistedValuesInMemory
in interface LRUCachingMapConfiguration
public LRUCachingMapConfiguration setPersistedValuesInMemory(boolean persistedValuesInMemory)
LRUCachingMapConfiguration
false
the values for persisted storage will have to retrieved from persisted storage for each get, if true
all values is held in memory as well, this will have an effect on your memory usage.
Only applies for LRUCachingMap implementation which has persisted storage.setPersistedValuesInMemory
in interface LRUCachingMapConfiguration
persistedValuesInMemory
- is persisted values held in memory.public DefaultLRUCachingMapConfiguration noExtendTime()
public DefaultLRUCachingMapConfiguration noMaxExtendCount()
public DefaultLRUCachingMapConfiguration noAutoCleanup()
CleanupTimerRunnable
public final DefaultLRUCachingMapConfiguration setExtendTimeSpan(TimeSpan extendTimeSpan) throws NullPointerException
extendTimeSpan
- the timespan for extendTime.NullPointerException
- if the extendTimeSpan is null
.public final DefaultLRUCachingMapConfiguration setCleanupIntervalTimeSpan(TimeSpan cleanupIntervalTimeSpan) throws NullPointerException
cleanupIntervalTimeSpan
- the timespan for cleanupIntervalTime.NullPointerException
- if the cleanupIntervalTimeSpan is null
.public final DefaultLRUCachingMapConfiguration setExpireTimeSpan(TimeSpan expireTimeSpan) throws IllegalArgumentException, NullPointerException
expireTimeSpan
- the timespan for expireTime.IllegalArgumentException
NullPointerException
- if the expireTimeSpan is null
.Copyright © 2016. All rights reserved.