diff --git a/redisson/src/main/java/org/redisson/config/Config.java b/redisson/src/main/java/org/redisson/config/Config.java index 1edabd781..95c9c2316 100644 --- a/redisson/src/main/java/org/redisson/config/Config.java +++ b/redisson/src/main/java/org/redisson/config/Config.java @@ -84,7 +84,10 @@ public class Config { private boolean useScriptCache = false; private int minCleanUpDelay = 5; + private int maxCleanUpDelay = 30*60; + + private int cleanUpKeysAmount = 100; /** * AddressResolverGroupFactory switch between default and round robin @@ -104,6 +107,7 @@ public class Config { setMinCleanUpDelay(oldConf.getMinCleanUpDelay()); setMaxCleanUpDelay(oldConf.getMaxCleanUpDelay()); + setCleanUpKeysAmount(oldConf.getCleanUpKeysAmount()); setDecodeInExecutor(oldConf.isDecodeInExecutor()); setUseScriptCache(oldConf.isUseScriptCache()); 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. + *
+ * Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects. *
- * Used in JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects
+ * Default is 5
.
*
* @param minCleanUpDelay - delay in seconds
* @return config
@@ -719,10 +725,12 @@ 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.
*
- * Used in JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects - * + * Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects. + *
+ * Default is 1800
.
+ *
* @param maxCleanUpDelay - delay in seconds
* @return config
*/
@@ -731,6 +739,23 @@ public class Config {
return this;
}
-
-
+ public int getCleanUpKeysAmount() {
+ return cleanUpKeysAmount;
+ }
+
+ /**
+ * Defines expired keys amount deleted per single operation during clean up process of expired entries.
+ *
+ * Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects. + *
+ * Default is 100
.
+ *
+ * @param cleanUpKeysAmount - delay in seconds
+ * @return config
+ */
+ public Config setCleanUpKeysAmount(int cleanUpKeysAmount) {
+ this.cleanUpKeysAmount = cleanUpKeysAmount;
+ return this;
+ }
+
}
diff --git a/redisson/src/main/java/org/redisson/eviction/EvictionTask.java b/redisson/src/main/java/org/redisson/eviction/EvictionTask.java
index 9e7ef15ae..2274d5c03 100644
--- a/redisson/src/main/java/org/redisson/eviction/EvictionTask.java
+++ b/redisson/src/main/java/org/redisson/eviction/EvictionTask.java
@@ -36,7 +36,7 @@ abstract class EvictionTask implements Runnable {
final Deque