Feature - cleanUpKeysAmount setting added. #2554

pull/2577/head
Nikita Koksharov 5 years ago
parent 573199128d
commit 62de066ee2

@ -84,8 +84,11 @@ public class Config {
private boolean useScriptCache = false; private boolean useScriptCache = false;
private int minCleanUpDelay = 5; private int minCleanUpDelay = 5;
private int maxCleanUpDelay = 30*60; private int maxCleanUpDelay = 30*60;
private int cleanUpKeysAmount = 100;
/** /**
* AddressResolverGroupFactory switch between default and round robin * AddressResolverGroupFactory switch between default and round robin
*/ */
@ -104,6 +107,7 @@ public class Config {
setMinCleanUpDelay(oldConf.getMinCleanUpDelay()); setMinCleanUpDelay(oldConf.getMinCleanUpDelay());
setMaxCleanUpDelay(oldConf.getMaxCleanUpDelay()); setMaxCleanUpDelay(oldConf.getMaxCleanUpDelay());
setCleanUpKeysAmount(oldConf.getCleanUpKeysAmount());
setDecodeInExecutor(oldConf.isDecodeInExecutor()); setDecodeInExecutor(oldConf.isDecodeInExecutor());
setUseScriptCache(oldConf.isUseScriptCache()); setUseScriptCache(oldConf.isUseScriptCache());
setKeepPubSubOrder(oldConf.isKeepPubSubOrder()); setKeepPubSubOrder(oldConf.isKeepPubSubOrder());
@ -702,9 +706,11 @@ public class Config {
} }
/** /**
* Defines minimal delay of clean up process for expired entries. * Defines minimum delay in seconds for clean up process of expired entries.
* <p> * <p>
* Used in JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects * Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects.
* <p>
* Default is <code>5</code>.
* *
* @param minCleanUpDelay - delay in seconds * @param minCleanUpDelay - delay in seconds
* @return config * @return config
@ -719,9 +725,11 @@ public class Config {
} }
/** /**
* Defines maximal delay of clean up process for expired entries. * Defines maximum delay in seconds for clean up process of expired entries.
* <p>
* Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects.
* <p> * <p>
* Used in JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects * Default is <code>1800</code>.
* *
* @param maxCleanUpDelay - delay in seconds * @param maxCleanUpDelay - delay in seconds
* @return config * @return config
@ -731,6 +739,23 @@ public class Config {
return this; return this;
} }
public int getCleanUpKeysAmount() {
return cleanUpKeysAmount;
}
/**
* Defines expired keys amount deleted per single operation during clean up process of expired entries.
* <p>
* Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects.
* <p>
* Default is <code>100</code>.
*
* @param cleanUpKeysAmount - delay in seconds
* @return config
*/
public Config setCleanUpKeysAmount(int cleanUpKeysAmount) {
this.cleanUpKeysAmount = cleanUpKeysAmount;
return this;
}
} }

@ -36,7 +36,7 @@ abstract class EvictionTask implements Runnable {
final Deque<Integer> sizeHistory = new LinkedList<Integer>(); final Deque<Integer> sizeHistory = new LinkedList<Integer>();
final int minDelay; final int minDelay;
final int maxDelay; final int maxDelay;
final int keysLimit = 100; final int keysLimit;
int delay = 5; int delay = 5;
@ -47,6 +47,7 @@ abstract class EvictionTask implements Runnable {
this.executor = executor; this.executor = executor;
this.minDelay = executor.getConnectionManager().getCfg().getMinCleanUpDelay(); this.minDelay = executor.getConnectionManager().getCfg().getMinCleanUpDelay();
this.maxDelay = executor.getConnectionManager().getCfg().getMaxCleanUpDelay(); this.maxDelay = executor.getConnectionManager().getCfg().getMaxCleanUpDelay();
this.keysLimit = executor.getConnectionManager().getCfg().getCleanUpKeysAmount();
} }
public void schedule() { public void schedule() {

Loading…
Cancel
Save