You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2026/03/19 09:13:44 UTC
(commons-jcs) branch master updated (fa13fb41 -> c646b1d3)
This is an automated email from the ASF dual-hosted git repository.
tv pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
from fa13fb41 Bump actions/upload-artifact from 6.0.0 to 7.0.0
new 8d0bcdf0 Fix documentation and case-sensitive naming of configuration properties
new 578e11f3 Support Duration as a data type
new f8c2f629 Change type of PoolConfiguration.keepAliveTime to Duration
new 396284d1 Change type of JDBCDiskCacheAttributes.ShrinkerInterval to Duration
new e6a509e8 Change type of CompositeCacheAttributes.ShrinkerInterval to Duration
new 13e8707a Change type of CompositeCacheAttributes.MaxMemoryIdleTime to Duration
new b5cf5909 Use java.time.Instant instead of Unix time
new 4ce038a8 Change type of ElementAttributes.MaxLife and MaxIdleTime to Duration
new 3f72abf3 Replace System.currentTimeMillis() with Instant.now()
new 69189732 Fix scope
new c646b1d3 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-jcs.git
The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../commons/jcs4/admin/CacheElementInfo.java | 6 +-
.../apache/commons/jcs4/admin/JCSAdminBean.java | 17 +--
.../jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java | 29 ++--
.../disk/jdbc/JDBCDiskCacheAttributes.java | 8 +-
.../commons/jcs4/engine/CacheEventQueue.java | 3 +-
.../jcs4/engine/CompositeCacheAttributes.java | 80 ++++------
.../commons/jcs4/engine/ElementAttributes.java | 108 +++++++-------
.../engine/behavior/ICompositeCacheAttributes.java | 45 ++----
.../jcs4/engine/behavior/IElementAttributes.java | 36 +++--
.../jcs4/engine/control/CompositeCache.java | 50 +++----
.../engine/control/event/ElementEventQueue.java | 5 +-
.../commons/jcs4/engine/logging/CacheEvent.java | 10 +-
.../AbstractDoubleLinkedListMemoryCache.java | 4 +-
.../jcs4/engine/memory/AbstractMemoryCache.java | 2 +-
.../jcs4/engine/memory/lru/LHMLRUMemoryCache.java | 6 +-
.../engine/memory/shrinking/ShrinkerThread.java | 48 +++---
.../memory/soft/SoftReferenceMemoryCache.java | 4 +-
.../jcs4/utils/config/ConfigurationBuilder.java | 37 ++---
.../commons/jcs4/utils/config/PropertySetter.java | 30 ++--
.../jcs4/utils/discovery/DiscoveredService.java | 9 +-
.../jcs4/utils/discovery/UDPDiscoveryReceiver.java | 3 +-
.../jcs4/utils/discovery/UDPDiscoveryService.java | 5 +-
.../jcs4/utils/threadpool/PoolConfiguration.java | 20 +--
.../jcs4/utils/threadpool/ThreadPoolManager.java | 4 +-
.../commons/jcs4/utils/timing/ElapsedTimer.java | 9 +-
commons-jcs4-core/src/test/conf/cache.ccf | 11 +-
commons-jcs4-core/src/test/conf/remote.cache.ccf | 14 +-
.../jcs4/JCSCacheElementRetrievalUnitTest.java | 9 +-
.../commons/jcs4/access/CacheAccessUnitTest.java | 27 ++--
.../jcs4/access/SystemPropertyUnitTest.java | 4 +-
.../commons/jcs4/access/TestCacheAccess.java | 68 ++++-----
.../indexed/AbstractIndexDiskCacheUnitTest.java | 9 +-
.../disk/indexed/IndexDiskCacheSizeUnitTest.java | 16 +-
.../IndexedDiskCacheConcurrentUnitTest.java | 1 -
.../remote/RemoteCacheListenerUnitTest.java | 12 +-
.../jcs4/engine/SystemPropertyUsageUnitTest.java | 4 +-
.../jcs4/engine/TestCompositeCacheAttributes.java | 92 ++++++------
.../commons/jcs4/engine/TestElementAttributes.java | 37 ++---
.../CompositeCacheConfiguratorUnitTest.java | 2 +-
.../control/CompositeCacheDiskUsageUnitTest.java | 20 +--
.../control/event/SimpleEventHandlingUnitTest.java | 14 +-
.../memory/lru/LHMLRUMemoryCacheUnitTest.java | 16 +-
.../engine/memory/mru/MRUMemoryCacheUnitTest.java | 16 +-
.../memory/shrinking/ShrinkerThreadUnitTest.java | 78 ++++++----
.../soft/SoftReferenceMemoryCacheUnitTest.java | 12 +-
.../jcs4/utils/config/PropertySetterUnitTest.java | 5 +-
.../discovery/UDPDiscoveryServiceUnitTest.java | 13 +-
.../SerializationConversionUtilUnitTest.java | 18 ++-
.../src/test/test-conf/TestBlockDiskCache.ccf | 6 +-
.../src/test/test-conf/TestBlockDiskCacheCon.ccf | 8 +-
.../src/test/test-conf/TestBlockDiskCacheHuge.ccf | 4 +-
.../src/test/test-conf/TestDiskCache.ccf | 6 +-
.../src/test/test-conf/TestDiskCacheCon.ccf | 8 +-
.../src/test/test-conf/TestDiskCacheHuge.ccf | 4 +-
.../src/test/test-conf/TestDiskCacheNoMemory.ccf | 6 +-
.../test/test-conf/TestDiskCacheUsagePattern.ccf | 8 +-
.../src/test/test-conf/TestElementSerializer.ccf | 2 +-
.../src/test/test-conf/TestHSQLDiskCache.ccf | 10 +-
.../test/test-conf/TestHSQLDiskCacheConcurrent.ccf | 10 +-
.../src/test/test-conf/TestJCS-73.ccf | 4 +-
.../src/test/test-conf/TestJCSvHashtablePerf.ccf | 6 +-
.../src/test/test-conf/TestJDBCDiskCache.ccf | 10 +-
.../test/test-conf/TestJDBCDiskCacheRemoval.ccf | 10 +-
.../test/test-conf/TestJDBCDiskCacheSharedPool.ccf | 10 +-
.../src/test/test-conf/TestJDBCDiskCacheShrink.ccf | 16 +-
.../src/test/test-conf/TestMRUCache.ccf | 8 +-
.../src/test/test-conf/TestMySQLDiskCache.ccf | 10 +-
.../src/test/test-conf/TestRemoteClient.ccf | 8 +-
.../src/test/test-conf/TestRemoteHttpCache.ccf | 8 +-
.../src/test/test-conf/TestRemoteServer.ccf | 10 +-
.../src/test/test-conf/TestRemoval.ccf | 6 +-
.../src/test/test-conf/TestSimpleEventHandling.ccf | 6 +-
.../src/test/test-conf/TestSoftReferenceCache.ccf | 6 +-
.../src/test/test-conf/TestTCPLateralCache.ccf | 6 +-
.../test-conf/TestTCPLateralIssueRemoveCache.ccf | 6 +-
.../src/test/test-conf/TestZeroSizeCache.ccf | 8 +-
commons-jcs4-core/src/test/test-conf/cache.ccf | 6 +-
.../src/test/test-conf/thread_pool.properties | 12 +-
.../org/apache/commons/jcs4/jcache/JCSCache.java | 36 +++--
.../commons/jcs4/jcache/JCSCachingManager.java | 11 +-
src/site/xdoc/BasicJCSConfiguration.xml | 12 +-
src/site/xdoc/BlockDiskCache.xml | 4 +-
src/site/xdoc/ElementAttributes.xml | 164 +++++++++++++--------
src/site/xdoc/IndexedDiskAuxCache.xml | 15 +-
src/site/xdoc/IndexedDiskCacheProperties.xml | 2 +-
src/site/xdoc/JDBCDiskCache.xml | 32 ++--
src/site/xdoc/JDBCDiskCacheProperties.xml | 12 +-
src/site/xdoc/MySQLDiskCacheProperties.xml | 2 +-
src/site/xdoc/RegionProperties.xml | 39 +++--
src/site/xdoc/UpgradingFrom3x.xml | 96 ++++++++++--
src/site/xdoc/UsingJCSBasicWeb.xml | 8 +-
src/site/xdoc/getting_started/intro.xml | 12 +-
92 files changed, 925 insertions(+), 824 deletions(-)
(commons-jcs) 05/11: Change type of CompositeCacheAttributes.ShrinkerInterval to Duration
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit e6a509e8dacf2aac32f9287b6563d30ddde0f611
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Wed Mar 18 15:38:13 2026 +0100
Change type of CompositeCacheAttributes.ShrinkerInterval to Duration
---
.../apache/commons/jcs4/engine/CompositeCacheAttributes.java | 12 +++++++-----
.../jcs4/engine/behavior/ICompositeCacheAttributes.java | 5 +++--
.../apache/commons/jcs4/engine/control/CompositeCache.java | 2 +-
commons-jcs4-core/src/test/conf/cache.ccf | 5 +----
commons-jcs4-core/src/test/conf/remote.cache.ccf | 8 +-------
.../commons/jcs4/engine/TestCompositeCacheAttributes.java | 10 +++++-----
commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf | 2 +-
.../src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf | 2 +-
commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf | 2 +-
commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf | 2 +-
.../src/test/test-conf/TestJDBCDiskCacheRemoval.ccf | 2 +-
.../src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf | 2 +-
.../src/test/test-conf/TestJDBCDiskCacheShrink.ccf | 2 +-
commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf | 2 +-
commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf | 2 +-
commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf | 2 +-
commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf | 2 +-
commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf | 4 ++--
commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf | 2 +-
.../org/apache/commons/jcs4/jcache/JCSCachingManager.java | 2 +-
src/site/xdoc/BasicJCSConfiguration.xml | 6 +++---
src/site/xdoc/ElementAttributes.xml | 2 +-
src/site/xdoc/IndexedDiskAuxCache.xml | 2 +-
src/site/xdoc/JDBCDiskCache.xml | 6 +++---
src/site/xdoc/RegionProperties.xml | 4 ++--
src/site/xdoc/UpgradingFrom3x.xml | 10 ++++++++++
src/site/xdoc/getting_started/intro.xml | 4 ++--
27 files changed, 55 insertions(+), 51 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
index 6b5484af..c4355cdf 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
@@ -19,6 +19,8 @@ package org.apache.commons.jcs4.engine;
* under the License.
*/
+import java.time.Duration;
+
import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes;
/**
@@ -38,8 +40,8 @@ public record CompositeCacheAttributes(
/** Whether or not we should run the memory shrinker thread. */
boolean UseMemoryShrinker,
- /** ShrinkerIntervalSeconds */
- long ShrinkerIntervalSeconds,
+ /** ShrinkerInterval */
+ Duration ShrinkerInterval,
/** The maximum number the shrinker will spool to disk per run. */
int MaxSpoolPerRun,
@@ -67,7 +69,7 @@ public record CompositeCacheAttributes(
private static final boolean DEFAULT_USE_SHRINKER = false;
/** Default interval to run the shrinker */
- private static final int DEFAULT_SHRINKER_INTERVAL_SECONDS = 30;
+ private static final Duration DEFAULT_SHRINKER_INTERVAL = Duration.ofSeconds(30);
/** Default */
private static final int DEFAULT_MAX_SPOOL_PER_RUN = -1;
@@ -86,7 +88,7 @@ public record CompositeCacheAttributes(
null,
DEFAULT_MAX_OBJECTS,
DEFAULT_USE_SHRINKER,
- DEFAULT_SHRINKER_INTERVAL_SECONDS,
+ DEFAULT_SHRINKER_INTERVAL,
DEFAULT_MAX_SPOOL_PER_RUN,
DEFAULT_MAX_MEMORY_IDLE_TIME_SECONDS,
DEFAULT_MEMORY_CACHE_NAME,
@@ -113,7 +115,7 @@ public record CompositeCacheAttributes(
return new CompositeCacheAttributes(s,
MaxObjects(),
UseMemoryShrinker(),
- ShrinkerIntervalSeconds(),
+ ShrinkerInterval(),
MaxSpoolPerRun(),
MaxMemoryIdleTimeSeconds(),
MemoryCacheName(),
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
index e7727720..abc912f1 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
@@ -20,6 +20,7 @@ package org.apache.commons.jcs4.engine.behavior;
*/
import java.io.Serializable;
+import java.time.Duration;
/**
* This defines the minimal behavior for the Cache Configuration settings.
@@ -86,9 +87,9 @@ public interface ICompositeCacheAttributes
* If UseMemoryShrinker is true the memory cache should auto-expire elements
* to reclaim space. This gets the shrinker interval.
*
- * @return The ShrinkerIntervalSeconds value
+ * @return The ShrinkerInterval value
*/
- long ShrinkerIntervalSeconds();
+ Duration ShrinkerInterval();
/**
* Number to send to disk at time when memory is full.
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
index 7ce1642d..6a947864 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
@@ -1413,7 +1413,7 @@ public class CompositeCache<K, V>
if (cacheAttr.UseMemoryShrinker())
{
future = scheduledExecutor.scheduleAtFixedRate(
- new ShrinkerThread<>(this), 0, cacheAttr.ShrinkerIntervalSeconds(),
+ new ShrinkerThread<>(this), 0, cacheAttr.ShrinkerInterval().toSeconds(),
TimeUnit.SECONDS);
}
diff --git a/commons-jcs4-core/src/test/conf/cache.ccf b/commons-jcs4-core/src/test/conf/cache.ccf
index cfc3fc5e..2250506d 100644
--- a/commons-jcs4-core/src/test/conf/cache.ccf
+++ b/commons-jcs4-core/src/test/conf/cache.ccf
@@ -18,13 +18,10 @@
# ################# DEFAULT CACHE REGION #####################
# sets the default aux value for any non configured caches
jcs.default=DC
-jcs.default.cacheattributes=org.apache.commons.jcs4.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=200001
-jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
-jcs.default.elementattributes=org.apache.commons.jcs4.engine.ElementAttributes
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/conf/remote.cache.ccf b/commons-jcs4-core/src/test/conf/remote.cache.ccf
index 987091bc..65c0e413 100644
--- a/commons-jcs4-core/src/test/conf/remote.cache.ccf
+++ b/commons-jcs4-core/src/test/conf/remote.cache.ccf
@@ -28,13 +28,10 @@ jcs.remotecache.serverattributes.LocalClusterConsistency=true
# ################# DEFAULT CACHE REGION #####################
# sets the default aux value for any non configured caches
jcs.default=DC,RCluster
-jcs.default.cacheattributes=org.apache.commons.jcs4.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=200000
-jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
-jcs.default.elementattributes=org.apache.commons.jcs4.engine.ElementAttributes
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=7000
jcs.default.elementattributes.MaxIdleTime=1800
@@ -46,7 +43,6 @@ jcs.default.elementattributes.IsLateral=true
# #############################################################
# ################# CACHE REGIONS AVAILABLE ###################
jcs.region.testCache1=DC,RCluster
-jcs.region.testCache1.cacheattributes=org.apache.commons.jcs4.engine.CompositeCacheAttributes
jcs.region.testCache1.cacheattributes.MaxObjects=200002
@@ -54,7 +50,6 @@ jcs.region.testCache1.cacheattributes.MaxObjects=200002
# ################# AUXILIARY CACHES AVAILABLE ################
# server to update for clustering -- remote.cache2.ccf(1102) and remote.cache3.ccf(1103)
jcs.auxiliary.RCluster=org.apache.commons.jcs4.auxiliary.remote.RemoteCacheFactory
-jcs.auxiliary.RCluster.attributes=org.apache.commons.jcs4.auxiliary.remote.RemoteCacheAttributes
jcs.auxiliary.RCluster.attributes.RemoteTypeName=CLUSTER
jcs.auxiliary.RCluster.attributes.RemoveUponRemotePut=false
jcs.auxiliary.RCluster.attributes.ClusterServers=localhost:1102
@@ -63,6 +58,5 @@ jcs.auxiliary.RCluster.attributes.LocalClusterConsistency=true
jcs.auxiliary.DC=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheFactory
-jcs.auxiliary.DC.attributes=org.apache.commons.jcs4.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=@project_home@/raf/remote
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
index 4e3ff276..0771c477 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
@@ -41,7 +41,7 @@ public class TestCompositeCacheAttributes
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
maxObjects,
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
- CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
memoryCacheName,
@@ -62,7 +62,7 @@ public class TestCompositeCacheAttributes
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
CompositeCacheAttributes.defaults().MaxObjects(),
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
- CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().ShrinkerInterval(),
maxSpoolPerRun,
maxMemoryIdleTimeSeconds,
memoryCacheName,
@@ -81,7 +81,7 @@ public class TestCompositeCacheAttributes
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
maxObjects,
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
- CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
CompositeCacheAttributes.defaults().MemoryCacheName(),
@@ -99,7 +99,7 @@ public class TestCompositeCacheAttributes
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
CompositeCacheAttributes.defaults().MaxObjects(),
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
- CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
maxMemoryIdleTimeSeconds,
CompositeCacheAttributes.defaults().MemoryCacheName(),
@@ -117,7 +117,7 @@ public class TestCompositeCacheAttributes
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
CompositeCacheAttributes.defaults().MaxObjects(),
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
- CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
CompositeCacheAttributes.defaults().MemoryCacheName(),
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
index bd1fbaf5..5a781cf1 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
@@ -21,7 +21,7 @@ jcs.default=HSQL
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
index d05e7e8c..c4a82df8 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
@@ -21,7 +21,7 @@ jcs.default=HSQL
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf
index b466763c..d615f974 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf
@@ -21,7 +21,7 @@ jcs.default.cacheattributes.MaxObjects=-1
jcs.default.cacheattributes.DiskUsagePattern=UPDATE
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=10
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=10
+jcs.default.cacheattributes.ShrinkerInterval=PT10s
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsLateral=false
jcs.default.elementattributes.IsEternal=true
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
index fedbb061..4c4dbee6 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
@@ -20,7 +20,7 @@
jcs.default=JDBC
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
index 70a6d8f7..e71e1295 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
@@ -21,7 +21,7 @@ jcs.default=JDBC
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
index 3bbf75e0..3038c078 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
@@ -20,7 +20,7 @@
jcs.default=JDBC_0
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
index a45401bf..92ff99ed 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
@@ -20,7 +20,7 @@
jcs.default=JDBC
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
index 306f2200..470ad265 100644
--- a/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
@@ -22,7 +22,7 @@ jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.mru.MRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=1
+jcs.default.cacheattributes.ShrinkerInterval=PT1s
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=600
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
index f602bdc1..92615687 100644
--- a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
@@ -23,7 +23,7 @@ jcs.default=MYSQL
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
index 737a86a7..feff2939 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
@@ -21,7 +21,7 @@ jcs.default=RC
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
index e43561da..f5977a87 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
@@ -21,7 +21,7 @@ jcs.default=RC
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
index bccfbe39..97ba0acf 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
@@ -31,8 +31,8 @@ jcs.default=
jcs.default.cacheattributes.MaxObjects=200000
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=7000
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf b/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
index a455d266..40f53809 100644
--- a/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
@@ -21,7 +21,7 @@ jcs.default=
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=1
+jcs.default.cacheattributes.ShrinkerInterval=PT1s
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=600
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
index c5bd2823..7842a0c7 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
@@ -83,7 +83,7 @@ public class JCSCachingManager implements CacheManager
jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
- jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+ jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes=org.apache.commons.jcs4.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/src/site/xdoc/BasicJCSConfiguration.xml b/src/site/xdoc/BasicJCSConfiguration.xml
index 6dfe109a..508da08a 100644
--- a/src/site/xdoc/BasicJCSConfiguration.xml
+++ b/src/site/xdoc/BasicJCSConfiguration.xml
@@ -54,7 +54,7 @@ jcs.default.cacheattributes.MaxObjects=1000
<source><![CDATA[
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.cacheattributes.MaxSpoolPerRun=500
jcs.default.elementattributes.IsEternal=false
]]></source>
@@ -85,7 +85,7 @@ jcs.region.testCache1=DC
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT1m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
jcs.region.testCache1.elementattributes.IsEternal=false
]]></source>
@@ -141,7 +141,7 @@ jcs.region.testCache1=DC,LTCP
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT1m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
jcs.region.testCache1.elementattributes.IsEternal=false
diff --git a/src/site/xdoc/ElementAttributes.xml b/src/site/xdoc/ElementAttributes.xml
index fbfb6162..9f74fbf4 100644
--- a/src/site/xdoc/ElementAttributes.xml
+++ b/src/site/xdoc/ElementAttributes.xml
@@ -51,7 +51,7 @@ jcs.default=DC
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/src/site/xdoc/IndexedDiskAuxCache.xml b/src/site/xdoc/IndexedDiskAuxCache.xml
index 94f12fb5..3fe1fe17 100644
--- a/src/site/xdoc/IndexedDiskAuxCache.xml
+++ b/src/site/xdoc/IndexedDiskAuxCache.xml
@@ -239,7 +239,7 @@ jcs.default=DC2
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/src/site/xdoc/JDBCDiskCache.xml b/src/site/xdoc/JDBCDiskCache.xml
index e9378389..4f3a769d 100644
--- a/src/site/xdoc/JDBCDiskCache.xml
+++ b/src/site/xdoc/JDBCDiskCache.xml
@@ -41,7 +41,7 @@ jcs.default=MYSQL,RCluster
jcs.default.cacheattributes.MaxObjects=5000
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=7200
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=14400
jcs.default.elementattributes.MaxIdleTime=14400
@@ -90,7 +90,7 @@ thread_pool.disk_cache_event_queue.startUpSize=10
jcs.default=JDBC_0
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
@@ -155,7 +155,7 @@ thread_pool.disk_cache_event_queue.startUpSize=10
jcs.default=JDBC_0
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/src/site/xdoc/RegionProperties.xml b/src/site/xdoc/RegionProperties.xml
index 9e479841..a5f23d70 100644
--- a/src/site/xdoc/RegionProperties.xml
+++ b/src/site/xdoc/RegionProperties.xml
@@ -260,14 +260,14 @@ jcs.default=
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
# optional region "testCache1" specific configuration settings (only those that differ from default)
jcs.region.testCache1=
jcs.region.testCache1.cacheattributes.MaxObjects=123456
-jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=30
+jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT30s
jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=300
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=100
jcs.region.testCache1.elementattributes.MaxLife=60000
diff --git a/src/site/xdoc/UpgradingFrom3x.xml b/src/site/xdoc/UpgradingFrom3x.xml
index 0bdd6953..b1105516 100644
--- a/src/site/xdoc/UpgradingFrom3x.xml
+++ b/src/site/xdoc/UpgradingFrom3x.xml
@@ -138,6 +138,11 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
<td>DiskUsagePatternName</td>
<td>DiskUsagePattern</td>
</tr>
+ <tr>
+ <td></td>
+ <td>ShrinkerIntervalSeconds</td>
+ <td>ShrinkerInterval</td>
+ </tr>
<tr>
<td>Element configuration (ElementAttributes)</td>
<td>IdleTime</td>
@@ -182,6 +187,11 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
<th>Property Name</th>
<th>Default Value</th>
</tr>
+ <tr>
+ <td>Region configuration (CompositeCacheAttributes)</td>
+ <td>ShrinkerInterval</td>
+ <td>PT30s</td>
+ </tr>
<tr>
<td>Thread Pool Configuration (thread_pool, PoolConfiguration)</td>
<td>keepAliveTime</td>
diff --git a/src/site/xdoc/getting_started/intro.xml b/src/site/xdoc/getting_started/intro.xml
index 277f323c..7faf8453 100644
--- a/src/site/xdoc/getting_started/intro.xml
+++ b/src/site/xdoc/getting_started/intro.xml
@@ -151,7 +151,7 @@ jcs.default=DC
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=21600
jcs.default.elementattributes.MaxIdleTime=1800
@@ -161,7 +161,7 @@ jcs.region.testCache1=DC
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=false
jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
-jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT1m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
jcs.region.testCache1.elementattributes.IsEternal=false
(commons-jcs) 06/11: Change type of CompositeCacheAttributes.MaxMemoryIdleTime to Duration
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 13e8707aed689b9348937aea00c5637428d8f93a
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Wed Mar 18 16:20:40 2026 +0100
Change type of CompositeCacheAttributes.MaxMemoryIdleTime to Duration
---
.../jcs4/engine/CompositeCacheAttributes.java | 13 +++---
.../engine/behavior/ICompositeCacheAttributes.java | 4 +-
.../engine/memory/shrinking/ShrinkerThread.java | 47 +++++++++-------------
commons-jcs4-core/src/test/conf/cache.ccf | 2 +-
commons-jcs4-core/src/test/conf/remote.cache.ccf | 2 +-
.../commons/jcs4/access/CacheAccessUnitTest.java | 13 +++---
.../jcs4/engine/TestCompositeCacheAttributes.java | 24 ++++++-----
.../memory/shrinking/ShrinkerThreadUnitTest.java | 36 ++++++++++-------
.../src/test/test-conf/TestHSQLDiskCache.ccf | 2 +-
.../test/test-conf/TestHSQLDiskCacheConcurrent.ccf | 2 +-
.../src/test/test-conf/TestJCS-73.ccf | 2 +-
.../src/test/test-conf/TestJDBCDiskCache.ccf | 2 +-
.../test/test-conf/TestJDBCDiskCacheRemoval.ccf | 2 +-
.../test/test-conf/TestJDBCDiskCacheSharedPool.ccf | 2 +-
.../src/test/test-conf/TestJDBCDiskCacheShrink.ccf | 2 +-
.../src/test/test-conf/TestMRUCache.ccf | 2 +-
.../src/test/test-conf/TestMySQLDiskCache.ccf | 2 +-
.../src/test/test-conf/TestRemoteClient.ccf | 2 +-
.../src/test/test-conf/TestRemoteHttpCache.ccf | 2 +-
.../src/test/test-conf/TestRemoteServer.ccf | 2 +-
.../src/test/test-conf/TestSoftReferenceCache.ccf | 2 +-
.../src/test/test-conf/TestZeroSizeCache.ccf | 2 +-
.../commons/jcs4/jcache/JCSCachingManager.java | 2 +-
src/site/xdoc/BasicJCSConfiguration.xml | 6 +--
src/site/xdoc/ElementAttributes.xml | 2 +-
src/site/xdoc/IndexedDiskAuxCache.xml | 2 +-
src/site/xdoc/JDBCDiskCache.xml | 6 +--
src/site/xdoc/RegionProperties.xml | 12 +++---
src/site/xdoc/UpgradingFrom3x.xml | 10 +++++
src/site/xdoc/getting_started/intro.xml | 4 +-
30 files changed, 113 insertions(+), 100 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
index c4355cdf..2352a0af 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
@@ -22,6 +22,7 @@ package org.apache.commons.jcs4.engine;
import java.time.Duration;
import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes;
+import org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache;
/**
* The CompositeCacheAttributes defines the general cache region settings. If a region is not
@@ -46,8 +47,8 @@ public record CompositeCacheAttributes(
/** The maximum number the shrinker will spool to disk per run. */
int MaxSpoolPerRun,
- /** MaxMemoryIdleTimeSeconds */
- long MaxMemoryIdleTimeSeconds,
+ /** MaxMemoryIdleTime */
+ Duration MaxMemoryIdleTime,
/** The name of the memory cache implementation class. */
String MemoryCacheName,
@@ -75,10 +76,10 @@ public record CompositeCacheAttributes(
private static final int DEFAULT_MAX_SPOOL_PER_RUN = -1;
/** Default */
- private static final int DEFAULT_MAX_MEMORY_IDLE_TIME_SECONDS = 60 * 120;
+ private static final Duration DEFAULT_MAX_MEMORY_IDLE_TIME = Duration.ofHours(2);
/** Default */
- private static final String DEFAULT_MEMORY_CACHE_NAME = "org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache";
+ private static final String DEFAULT_MEMORY_CACHE_NAME = LRUMemoryCache.class.getName();
/** Default number to send to disk at a time when memory fills. */
private static final int DEFAULT_CHUNK_SIZE = 2;
@@ -90,7 +91,7 @@ public record CompositeCacheAttributes(
DEFAULT_USE_SHRINKER,
DEFAULT_SHRINKER_INTERVAL,
DEFAULT_MAX_SPOOL_PER_RUN,
- DEFAULT_MAX_MEMORY_IDLE_TIME_SECONDS,
+ DEFAULT_MAX_MEMORY_IDLE_TIME,
DEFAULT_MEMORY_CACHE_NAME,
DiskUsagePatternEnum.SWAP,
DEFAULT_CHUNK_SIZE
@@ -117,7 +118,7 @@ public record CompositeCacheAttributes(
UseMemoryShrinker(),
ShrinkerInterval(),
MaxSpoolPerRun(),
- MaxMemoryIdleTimeSeconds(),
+ MaxMemoryIdleTime(),
MemoryCacheName(),
DiskUsagePattern(),
SpoolChunkSize());
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
index abc912f1..80114dde 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
@@ -56,9 +56,9 @@ public interface ICompositeCacheAttributes
* If UseMemoryShrinker is true the memory cache should auto-expire elements
* to reclaim space.
*
- * @return The MaxMemoryIdleTimeSeconds value
+ * @return The MaxMemoryIdleTime value
*/
- long MaxMemoryIdleTimeSeconds();
+ Duration MaxMemoryIdleTime();
/**
* Gets the maxObjects attribute of the ICompositeCacheAttributes object
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
index d946f406..e895c479 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
@@ -19,6 +19,8 @@ package org.apache.commons.jcs4.engine.memory.shrinking;
* under the License.
*/
+import java.time.Duration;
+import java.time.Instant;
import java.util.Set;
import org.apache.commons.jcs4.engine.behavior.ICacheElement;
@@ -42,7 +44,7 @@ public class ShrinkerThread<K, V>
private final CompositeCache<K, V> cache;
/** Maximum memory idle time for the whole cache */
- private final long maxMemoryIdleTime;
+ private final Duration maxMemoryIdleTime;
/** Maximum number of items to spool per run. Default is -1, or no limit. */
private final int maxSpoolPerRun;
@@ -58,24 +60,12 @@ public class ShrinkerThread<K, V>
public ShrinkerThread( final CompositeCache<K, V> cache )
{
this.cache = cache;
-
- final long maxMemoryIdleTimeSeconds = cache.getCacheAttributes().MaxMemoryIdleTimeSeconds();
-
- if ( maxMemoryIdleTimeSeconds < 0 )
- {
- this.maxMemoryIdleTime = -1;
- }
- else
- {
- this.maxMemoryIdleTime = maxMemoryIdleTimeSeconds * 1000;
- }
-
+ this.maxMemoryIdleTime = cache.getCacheAttributes().MaxMemoryIdleTime();
this.maxSpoolPerRun = cache.getCacheAttributes().MaxSpoolPerRun();
if ( this.maxSpoolPerRun != -1 )
{
this.spoolLimit = true;
}
-
}
/**
@@ -93,11 +83,12 @@ public class ShrinkerThread<K, V>
* without affecting the last access or position of the item. The item is checked for
* expiration, the expiration check has 3 parts:
* <ol>
- * <li>Has the cacheattributes.MaxMemoryIdleTimeSeconds defined for the region been exceeded? If
- * so, the item should be move to disk.</li> <li>Has the item exceeded MaxLifeSeconds defined in
- * the element attributes? If so, remove it.</li> <li>Has the item exceeded IdleTime defined in
- * the element attributes? If so, remove it. If there are event listeners registered for the
- * cache element, they will be called.</li>
+ * <li>Has the cacheattributes.MaxMemoryIdleTime defined for the region been exceeded? If
+ * so, the item should be move to disk.</li>
+ * <li>Has the item exceeded MaxLifeSeconds defined in the element attributes? If so,
+ * remove it.</li>
+ * <li>Has the item exceeded IdleTime defined in the element attributes? If so, remove it.
+ * If there are event listeners registered for the cache element, they will be called.</li>
* </ol>
* TODO Change element event handling to use the queue, then move the queue to the region and
* access via the Cache.
@@ -126,16 +117,15 @@ public class ShrinkerThread<K, V>
}
final IElementAttributes attributes = cacheElement.elementAttributes();
+ final Instant now = Instant.now();
boolean remove = false;
- final long now = System.currentTimeMillis();
-
// If the element is not eternal, check if it should be
// removed and remove it if so.
if ( !attributes.IsEternal() )
{
- remove = cache.isExpired( cacheElement, now,
+ remove = cache.isExpired( cacheElement, now.toEpochMilli(),
ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND,
ElementEventType.EXCEEDED_IDLETIME_BACKGROUND );
@@ -148,24 +138,25 @@ public class ShrinkerThread<K, V>
// If the item is not removed, check is it has been idle
// long enough to be spooled.
- if ( !remove && maxMemoryIdleTime != -1 )
+ if (!remove && !maxMemoryIdleTime.isNegative())
{
- if ( !spoolLimit || spoolCount < this.maxSpoolPerRun )
+ if (!spoolLimit || spoolCount < this.maxSpoolPerRun)
{
- final long lastAccessTime = attributes.lastAccessTime();
+ final Instant idleExpiryTime = Instant
+ .ofEpochMilli(attributes.lastAccessTime())
+ .plus(maxMemoryIdleTime);
- if ( lastAccessTime + maxMemoryIdleTime < now )
+ if (idleExpiryTime.isBefore(now))
{
log.debug( "Exceeded memory idle time: {0}", key );
// Shouldn't we ensure that the element is
// spooled before removing it from memory?
- // No the disk caches have a purgatory. If it fails
+ // Now the disk caches have a purgatory. If it fails
// to spool that does not affect the
// responsibilities of the memory cache.
spoolCount++;
-
memCache.remove( key );
memCache.waterfall( cacheElement );
}
diff --git a/commons-jcs4-core/src/test/conf/cache.ccf b/commons-jcs4-core/src/test/conf/cache.ccf
index 2250506d..db7bf102 100644
--- a/commons-jcs4-core/src/test/conf/cache.ccf
+++ b/commons-jcs4-core/src/test/conf/cache.ccf
@@ -20,7 +20,7 @@
jcs.default=DC
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/conf/remote.cache.ccf b/commons-jcs4-core/src/test/conf/remote.cache.ccf
index 65c0e413..cd10bde6 100644
--- a/commons-jcs4-core/src/test/conf/remote.cache.ccf
+++ b/commons-jcs4-core/src/test/conf/remote.cache.ccf
@@ -30,7 +30,7 @@ jcs.remotecache.serverattributes.LocalClusterConsistency=true
jcs.default=DC,RCluster
jcs.default.cacheattributes.MaxObjects=200000
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=7000
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
index 85b3abb4..8539e6fb 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
@@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+import java.time.Duration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -306,15 +307,15 @@ class CacheAccessUnitTest
void testRegionDefinitonWithAttributes()
throws Exception
{
- final long maxIdleTime = 8765;
+ final Duration maxIdleTime = Duration.ofSeconds(8765);
final CompositeCacheAttributes ca = TestCompositeCacheAttributes
- .withMaxMemoryIdleTimeSeconds(maxIdleTime);
+ .withMaxMemoryIdleTime(maxIdleTime);
final CacheAccess<String, String> access = JCS.getInstance( "testRegionDefinitonWithAttributes", ca );
assertNotNull( access, "We should have an access class" );
final ICompositeCacheAttributes ca2 = access.getCacheAttributes();
- assertEquals( ca.MaxMemoryIdleTimeSeconds(), ca2.MaxMemoryIdleTimeSeconds(), "Wrong idle time setting." );
+ assertEquals( ca.MaxMemoryIdleTime(), ca2.MaxMemoryIdleTime(), "Wrong idle time setting." );
}
/**
@@ -326,9 +327,9 @@ class CacheAccessUnitTest
void testRegionDefinitonWithBothAttributes()
throws Exception
{
- final long maxIdleTime = 8765;
+ final Duration maxIdleTime = Duration.ofSeconds(8765);
final CompositeCacheAttributes ca = TestCompositeCacheAttributes
- .withMaxMemoryIdleTimeSeconds(maxIdleTime);
+ .withMaxMemoryIdleTime(maxIdleTime);
final long maxLife = 9876;
final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
@@ -337,7 +338,7 @@ class CacheAccessUnitTest
assertNotNull( access, "We should have an access class" );
final ICompositeCacheAttributes ca2 = access.getCacheAttributes();
- assertEquals( ca.MaxMemoryIdleTimeSeconds(), ca2.MaxMemoryIdleTimeSeconds(), "Wrong idle time setting." );
+ assertEquals( ca.MaxMemoryIdleTime(), ca2.MaxMemoryIdleTime(), "Wrong idle time setting." );
}
/**
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
index 0771c477..1817172d 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
@@ -1,5 +1,7 @@
package org.apache.commons.jcs4.engine;
+import java.time.Duration;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -43,7 +45,7 @@ public class TestCompositeCacheAttributes
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
- CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
+ CompositeCacheAttributes.defaults().MaxMemoryIdleTime(),
memoryCacheName,
CompositeCacheAttributes.defaults().DiskUsagePattern(),
CompositeCacheAttributes.defaults().SpoolChunkSize());
@@ -53,18 +55,18 @@ public class TestCompositeCacheAttributes
* Get a CompositeCacheAttributes object suitable for tests
*
* @param memoryCacheName the new memoryCacheName value
- * @param maxMemoryIdleTimeSeconds the new maxMemoryIdleTimeSeconds value
+ * @param maxMemoryIdleTime the new maxMemoryIdleTime value
* @param maxSpoolPerRun the new maxSpoolPerRun value
*/
- public static CompositeCacheAttributes withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- String memoryCacheName, long maxMemoryIdleTimeSeconds, int maxSpoolPerRun)
+ public static CompositeCacheAttributes withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ String memoryCacheName, Duration maxMemoryIdleTime, int maxSpoolPerRun)
{
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
CompositeCacheAttributes.defaults().MaxObjects(),
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
CompositeCacheAttributes.defaults().ShrinkerInterval(),
maxSpoolPerRun,
- maxMemoryIdleTimeSeconds,
+ maxMemoryIdleTime,
memoryCacheName,
CompositeCacheAttributes.defaults().DiskUsagePattern(),
CompositeCacheAttributes.defaults().SpoolChunkSize());
@@ -83,25 +85,25 @@ public class TestCompositeCacheAttributes
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
- CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
+ CompositeCacheAttributes.defaults().MaxMemoryIdleTime(),
CompositeCacheAttributes.defaults().MemoryCacheName(),
CompositeCacheAttributes.defaults().DiskUsagePattern(),
spoolChunkSize);
}
/**
- * Sets the maximum memory idle-time in seconds of the cache.
+ * Sets the maximum memory idle-time of the cache.
*
- * @param maxMemoryIdleTimeSeconds the new maxMemoryIdleTimeSeconds value
+ * @param maxMemoryIdleTime the new maxMemoryIdleTime value
*/
- public static CompositeCacheAttributes withMaxMemoryIdleTimeSeconds(long maxMemoryIdleTimeSeconds)
+ public static CompositeCacheAttributes withMaxMemoryIdleTime(Duration maxMemoryIdleTime)
{
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
CompositeCacheAttributes.defaults().MaxObjects(),
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
- maxMemoryIdleTimeSeconds,
+ maxMemoryIdleTime,
CompositeCacheAttributes.defaults().MemoryCacheName(),
CompositeCacheAttributes.defaults().DiskUsagePattern(),
CompositeCacheAttributes.defaults().SpoolChunkSize());
@@ -119,7 +121,7 @@ public class TestCompositeCacheAttributes
CompositeCacheAttributes.defaults().UseMemoryShrinker(),
CompositeCacheAttributes.defaults().ShrinkerInterval(),
CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
- CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
+ CompositeCacheAttributes.defaults().MaxMemoryIdleTime(),
CompositeCacheAttributes.defaults().MemoryCacheName(),
diskUsagePattern,
CompositeCacheAttributes.defaults().SpoolChunkSize());
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
index 946bdd04..806c0277 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
@@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
+import java.time.Duration;
import org.apache.commons.jcs4.engine.CacheElement;
import org.apache.commons.jcs4.engine.CompositeCacheAttributes;
@@ -53,8 +54,9 @@ class ShrinkerThreadUnitTest
{
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
- .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
+ .withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ CompositeCacheAttributes.defaults().MemoryCacheName(),
+ Duration.ofSeconds(10), 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -87,8 +89,9 @@ class ShrinkerThreadUnitTest
{
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
- .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
+ .withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ CompositeCacheAttributes.defaults().MemoryCacheName(),
+ Duration.ofSeconds(10), 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -121,8 +124,9 @@ class ShrinkerThreadUnitTest
{
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
- .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
+ .withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ CompositeCacheAttributes.defaults().MemoryCacheName(),
+ Duration.ofSeconds(10), 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -155,8 +159,9 @@ class ShrinkerThreadUnitTest
{
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
- .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
+ .withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ CompositeCacheAttributes.defaults().MemoryCacheName(),
+ Duration.ofSeconds(10), 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -192,8 +197,9 @@ class ShrinkerThreadUnitTest
{
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
- .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- "org.apache.commons.jcs4.engine.memory.MockMemoryCache", 1, 10)
+ .withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ "org.apache.commons.jcs4.engine.memory.MockMemoryCache",
+ Duration.ofSeconds(1), 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -236,8 +242,9 @@ class ShrinkerThreadUnitTest
{
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
- .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- "org.apache.commons.jcs4.engine.memory.MockMemoryCache", 1, 3)
+ .withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ "org.apache.commons.jcs4.engine.memory.MockMemoryCache",
+ Duration.ofSeconds(1), 3)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -283,8 +290,9 @@ class ShrinkerThreadUnitTest
{
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
- .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- "org.apache.commons.jcs4.engine.memory.MockMemoryCache", 1, 3)
+ .withMemoryCacheNameMaxMemoryIdleTimeAndMaxSpoolPerRun(
+ "org.apache.commons.jcs4.engine.memory.MockMemoryCache",
+ Duration.ofSeconds(1), 3)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
index 5a781cf1..a4b04d4b 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
@@ -20,7 +20,7 @@
jcs.default=HSQL
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
index c4a82df8..c0994be5 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
@@ -20,7 +20,7 @@
jcs.default=HSQL
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf
index d615f974..d790c946 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf
@@ -20,7 +20,7 @@ jcs.default=CACHE
jcs.default.cacheattributes.MaxObjects=-1
jcs.default.cacheattributes.DiskUsagePattern=UPDATE
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=10
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT10s
jcs.default.cacheattributes.ShrinkerInterval=PT10s
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsLateral=false
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
index 4c4dbee6..6abbf934 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
@@ -19,7 +19,7 @@
jcs.default=JDBC
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
index e71e1295..54151af1 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
@@ -20,7 +20,7 @@
jcs.default=JDBC
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
index 3038c078..dbae3be2 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
@@ -19,7 +19,7 @@
jcs.default=JDBC_0
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
index 92ff99ed..ea64be8f 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
@@ -19,7 +19,7 @@
jcs.default=JDBC
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
index 470ad265..7fb0e72c 100644
--- a/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
@@ -21,7 +21,7 @@ jcs.default=
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.mru.MRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1s
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=600
diff --git a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
index 92615687..2ee668fb 100644
--- a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
@@ -22,7 +22,7 @@
jcs.default=MYSQL
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
index feff2939..81b344b6 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
@@ -20,7 +20,7 @@
jcs.default=RC
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
index f5977a87..0e0ca49c 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
@@ -20,7 +20,7 @@
jcs.default=RC
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
index 97ba0acf..f62ed072 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
@@ -30,7 +30,7 @@ jcs.remotecache.serverattributes.LocalClusterConsistency=true
jcs.default=
jcs.default.cacheattributes.MaxObjects=200000
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
diff --git a/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf b/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf
index c3413443..c493f3bc 100644
--- a/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf
@@ -19,7 +19,7 @@
jcs.default=
jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.soft.SoftReferenceMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=600
jcs.default.elementattributes.MaxIdleTime=1800
diff --git a/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf b/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
index 40f53809..3d13b088 100644
--- a/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
@@ -20,7 +20,7 @@
jcs.default=
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1s
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=600
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
index 7842a0c7..b7f458ec 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
@@ -82,7 +82,7 @@ public class JCSCachingManager implements CacheManager
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
- jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+ jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes=org.apache.commons.jcs4.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
diff --git a/src/site/xdoc/BasicJCSConfiguration.xml b/src/site/xdoc/BasicJCSConfiguration.xml
index 508da08a..34e3019a 100644
--- a/src/site/xdoc/BasicJCSConfiguration.xml
+++ b/src/site/xdoc/BasicJCSConfiguration.xml
@@ -53,7 +53,7 @@ jcs.default.cacheattributes.MaxObjects=1000
</p>
<source><![CDATA[
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.cacheattributes.MaxSpoolPerRun=500
jcs.default.elementattributes.IsEternal=false
@@ -84,7 +84,7 @@ jcs.default=DC
jcs.region.testCache1=DC
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
-jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.region.testCache1.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT1m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
jcs.region.testCache1.elementattributes.IsEternal=false
@@ -140,7 +140,7 @@ jcs.default.cacheattributes.MaxObjects=1000
jcs.region.testCache1=DC,LTCP
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
-jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.region.testCache1.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT1m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
jcs.region.testCache1.elementattributes.IsEternal=false
diff --git a/src/site/xdoc/ElementAttributes.xml b/src/site/xdoc/ElementAttributes.xml
index 9f74fbf4..3022df10 100644
--- a/src/site/xdoc/ElementAttributes.xml
+++ b/src/site/xdoc/ElementAttributes.xml
@@ -50,7 +50,7 @@
jcs.default=DC
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/src/site/xdoc/IndexedDiskAuxCache.xml b/src/site/xdoc/IndexedDiskAuxCache.xml
index 3fe1fe17..38996077 100644
--- a/src/site/xdoc/IndexedDiskAuxCache.xml
+++ b/src/site/xdoc/IndexedDiskAuxCache.xml
@@ -238,7 +238,7 @@ jcs.auxiliary.DC.attributes.DiskLimitType=COUNT
jcs.default=DC2
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/src/site/xdoc/JDBCDiskCache.xml b/src/site/xdoc/JDBCDiskCache.xml
index 4f3a769d..c796191f 100644
--- a/src/site/xdoc/JDBCDiskCache.xml
+++ b/src/site/xdoc/JDBCDiskCache.xml
@@ -40,7 +40,7 @@
jcs.default=MYSQL,RCluster
jcs.default.cacheattributes.MaxObjects=5000
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=7200
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT2h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=14400
@@ -89,7 +89,7 @@ thread_pool.disk_cache_event_queue.startUpSize=10
<![CDATA[
jcs.default=JDBC_0
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
@@ -154,7 +154,7 @@ thread_pool.disk_cache_event_queue.startUpSize=10
<![CDATA[
jcs.default=JDBC_0
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
diff --git a/src/site/xdoc/RegionProperties.xml b/src/site/xdoc/RegionProperties.xml
index a5f23d70..8f628af2 100644
--- a/src/site/xdoc/RegionProperties.xml
+++ b/src/site/xdoc/RegionProperties.xml
@@ -119,7 +119,7 @@
<td>false</td>
</tr>
<tr>
- <td>MaxMemoryIdleTimeSeconds</td>
+ <td>MaxMemoryIdleTime</td>
<td>
This is only used if you are using the
memory shrinker. If this value is set above
@@ -129,10 +129,10 @@
register an event handler on this event.
</td>
<td>N</td>
- <td>7200</td>
+ <td>PT2h</td>
</tr>
<tr>
- <td>ShrinkerIntervalSeconds</td>
+ <td>ShrinkerInterval</td>
<td>
This specifies how often the shrinker should
run, if it has been activated. If you set
@@ -140,7 +140,7 @@
setting has no effect.
</td>
<td>N</td>
- <td>30</td>
+ <td>PT30s</td>
</tr>
<tr>
<td>MaxSpoolPerRun</td>
@@ -259,7 +259,7 @@
jcs.default=
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
@@ -268,7 +268,7 @@ jcs.default.elementattributes.MaxLife=700
jcs.region.testCache1=
jcs.region.testCache1.cacheattributes.MaxObjects=123456
jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT30s
-jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=300
+jcs.region.testCache1.cacheattributes.MaxMemoryIdleTime=PT5m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=100
jcs.region.testCache1.elementattributes.MaxLife=60000
]]>
diff --git a/src/site/xdoc/UpgradingFrom3x.xml b/src/site/xdoc/UpgradingFrom3x.xml
index b1105516..3a65fc2c 100644
--- a/src/site/xdoc/UpgradingFrom3x.xml
+++ b/src/site/xdoc/UpgradingFrom3x.xml
@@ -138,6 +138,11 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
<td>DiskUsagePatternName</td>
<td>DiskUsagePattern</td>
</tr>
+ <tr>
+ <td></td>
+ <td>MaxMemoryIdleTimeSeconds</td>
+ <td>MaxMemoryIdleTime</td>
+ </tr>
<tr>
<td></td>
<td>ShrinkerIntervalSeconds</td>
@@ -189,6 +194,11 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
</tr>
<tr>
<td>Region configuration (CompositeCacheAttributes)</td>
+ <td>MaxMemoryIdleTime</td>
+ <td>PT2h</td>
+ </tr>
+ <tr>
+ <td></td>
<td>ShrinkerInterval</td>
<td>PT30s</td>
</tr>
diff --git a/src/site/xdoc/getting_started/intro.xml b/src/site/xdoc/getting_started/intro.xml
index 7faf8453..49dfbfa4 100644
--- a/src/site/xdoc/getting_started/intro.xml
+++ b/src/site/xdoc/getting_started/intro.xml
@@ -150,7 +150,7 @@
jcs.default=DC
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.UseMemoryShrinker=false
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=21600
@@ -160,7 +160,7 @@ jcs.default.elementattributes.MaxIdleTime=1800
jcs.region.testCache1=DC
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=false
-jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.region.testCache1.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT1m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=500
jcs.region.testCache1.elementattributes.IsEternal=false
(commons-jcs) 08/11: Change type of ElementAttributes.MaxLife and MaxIdleTime to Duration
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 4ce038a85d7a548bf9faabd188a54902f9661118
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Thu Mar 19 09:02:21 2026 +0100
Change type of ElementAttributes.MaxLife and MaxIdleTime to Duration
---
.../commons/jcs4/admin/CacheElementInfo.java | 6 ++++--
.../jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java | 19 ++++++++--------
.../commons/jcs4/engine/ElementAttributes.java | 25 +++++++---------------
.../jcs4/engine/behavior/IElementAttributes.java | 12 +++--------
.../jcs4/engine/control/CompositeCache.java | 10 ++++-----
commons-jcs4-core/src/test/conf/cache.ccf | 4 ++--
commons-jcs4-core/src/test/conf/remote.cache.ccf | 4 ++--
.../commons/jcs4/access/CacheAccessUnitTest.java | 8 +++----
.../remote/RemoteCacheListenerUnitTest.java | 8 +++++--
.../commons/jcs4/engine/TestElementAttributes.java | 10 ++++-----
.../control/event/SimpleEventHandlingUnitTest.java | 4 ++--
.../memory/shrinking/ShrinkerThreadUnitTest.java | 19 ++++++++++------
.../SerializationConversionUtilUnitTest.java | 10 ++++++---
.../src/test/test-conf/TestHSQLDiskCache.ccf | 4 ++--
.../test/test-conf/TestHSQLDiskCacheConcurrent.ccf | 4 ++--
.../src/test/test-conf/TestJDBCDiskCache.ccf | 4 ++--
.../test/test-conf/TestJDBCDiskCacheRemoval.ccf | 4 ++--
.../test/test-conf/TestJDBCDiskCacheSharedPool.ccf | 4 ++--
.../src/test/test-conf/TestJDBCDiskCacheShrink.ccf | 10 ++++-----
.../src/test/test-conf/TestMRUCache.ccf | 4 ++--
.../src/test/test-conf/TestMySQLDiskCache.ccf | 4 ++--
.../src/test/test-conf/TestRemoteClient.ccf | 4 ++--
.../src/test/test-conf/TestRemoteHttpCache.ccf | 4 ++--
.../src/test/test-conf/TestRemoteServer.ccf | 4 ++--
.../src/test/test-conf/TestSimpleEventHandling.ccf | 6 +++---
.../src/test/test-conf/TestSoftReferenceCache.ccf | 4 ++--
.../src/test/test-conf/TestZeroSizeCache.ccf | 4 ++--
.../org/apache/commons/jcs4/jcache/JCSCache.java | 18 +++++++---------
.../commons/jcs4/jcache/JCSCachingManager.java | 4 ++--
src/site/xdoc/ElementAttributes.xml | 20 ++++++++---------
src/site/xdoc/IndexedDiskAuxCache.xml | 4 ++--
src/site/xdoc/JDBCDiskCache.xml | 14 ++++++------
src/site/xdoc/RegionProperties.xml | 4 ++--
src/site/xdoc/UsingJCSBasicWeb.xml | 8 +++----
src/site/xdoc/getting_started/intro.xml | 4 ++--
35 files changed, 137 insertions(+), 142 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/CacheElementInfo.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/CacheElementInfo.java
index f88d1adf..d31274dd 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/CacheElementInfo.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/CacheElementInfo.java
@@ -1,5 +1,7 @@
package org.apache.commons.jcs4.admin;
+import java.time.Duration;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -33,7 +35,7 @@ public record CacheElementInfo(
String createTime,
/** Max life */
- long maxLifeSeconds,
+ Duration maxLife,
/** When it will expire */
long expiresInSeconds
@@ -50,7 +52,7 @@ public record CacheElementInfo(
buf.append( "\n Key [" ).append( key() ).append( "]" );
buf.append( "\n Eternal [" ).append( eternal() ).append( "]" );
buf.append( "\n CreateTime [" ).append( createTime() ).append( "]" );
- buf.append( "\n MaxLifeSeconds [" ).append( maxLifeSeconds() ).append( "]" );
+ buf.append( "\n MaxLifeSeconds [" ).append( maxLife() ).append( "]" );
buf.append( "\n ExpiresInSeconds [" ).append( expiresInSeconds() ).append( "]" );
return buf.toString();
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
index 1d3a07af..6088c4ca 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
@@ -25,6 +25,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
+import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -427,17 +428,17 @@ public class JDBCDiskCache<K, V>
psInsert.setString( 1, ce.key().toString() );
psInsert.setString( 2, getCacheName() );
psInsert.setBytes( 3, element );
- psInsert.setLong( 4, ce.elementAttributes().MaxLife() );
+ psInsert.setLong( 4, ce.elementAttributes().MaxLife().toSeconds() );
psInsert.setString( 5, ce.elementAttributes().IsEternal() ? "T" : "F" );
final Timestamp createTime = Timestamp.from(ce.elementAttributes().createTime());
psInsert.setTimestamp( 6, createTime );
- final long now = System.currentTimeMillis() / 1000;
- psInsert.setLong( 7, now );
+ final Instant now = Instant.now();
+ psInsert.setLong( 7, now.getEpochSecond() );
- final long expireTime = now + ce.elementAttributes().MaxLife();
- psInsert.setLong( 8, expireTime );
+ final Instant expireTime = now.plus(ce.elementAttributes().MaxLife());
+ psInsert.setLong( 8, expireTime.getEpochSecond() );
psInsert.execute();
}
@@ -480,11 +481,11 @@ public class JDBCDiskCache<K, V>
final Timestamp createTime = Timestamp.from(ce.elementAttributes().createTime());
psUpdate.setTimestamp( 2, createTime );
- final long now = System.currentTimeMillis() / 1000;
- psUpdate.setLong( 3, now );
+ final Instant now = Instant.now();
+ psUpdate.setLong( 3, now.getEpochSecond() );
- final long expireTime = now + ce.elementAttributes().MaxLife();
- psUpdate.setLong( 4, expireTime );
+ final Instant expireTime = now.plus(ce.elementAttributes().MaxLife());
+ psUpdate.setLong( 4, expireTime.getEpochSecond() );
psUpdate.setString( 5, (String) ce.key() );
psUpdate.setString( 6, getCacheName() );
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
index ae4f8b82..7fa28d89 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
@@ -56,13 +56,13 @@ public record ElementAttributes(
boolean IsEternal,
/** Max life */
- long MaxLife,
+ Duration MaxLife,
/**
* The maximum time an entry can be idle. Setting this to -1 causes the idle time check to be
* ignored.
*/
- long MaxIdleTime,
+ Duration MaxIdleTime,
/** The creation time. This is used to enforce the max life. */
Instant createTime,
@@ -70,9 +70,6 @@ public record ElementAttributes(
/** The last access time. This is used to enforce the max idle time. */
LastAccessHolder mutableLastAccessTime,
- /** The time factor to convert durations to milliseconds */
- long timeFactorForMilliseconds,
-
/**
* The list of Event handlers to use. This is transient, since the event handlers cannot usually
* be serialized. This means that you cannot attach a post serialization event to an item.
@@ -109,11 +106,9 @@ public record ElementAttributes(
/** Default */
private static final boolean DEFAULT_IS_ETERNAL = true;
/** Default */
- private static final long DEFAULT_MAX_LIFE = -1;
- /** Default */
- private static final long DEFAULT_MAX_IDLE_TIME = -1;
+ private static final Duration DEFAULT_MAX_LIFE = Duration.ofMillis(-1);
/** Default */
- private static final long DEFAULT_TIME_FACTOR = 1000;
+ private static final Duration DEFAULT_MAX_IDLE_TIME = Duration.ofMillis(-1);
/** Record with all defaults set */
private static final ElementAttributes DEFAULT = new ElementAttributes(
@@ -125,7 +120,6 @@ public record ElementAttributes(
DEFAULT_MAX_IDLE_TIME,
Instant.EPOCH,
new LastAccessHolder(Instant.EPOCH),
- DEFAULT_TIME_FACTOR,
new ArrayList<>());
/**
@@ -158,7 +152,6 @@ public record ElementAttributes(
from.MaxIdleTime(),
Instant.now(),
new LastAccessHolder(from.lastAccessTime()),
- from.timeFactorForMilliseconds(),
new ArrayList<>(from.elementEventHandlers()));
}
@@ -170,14 +163,12 @@ public record ElementAttributes(
boolean isLateral,
boolean isRemote,
boolean isEternal,
- long maxLife,
- long maxIdleTime,
- long timeFactorForMilliseconds
+ Duration maxLife,
+ Duration maxIdleTime
)
{
this(isSpool, isLateral, isRemote, isEternal, maxLife, maxIdleTime,
- Instant.now(), new LastAccessHolder(Instant.EPOCH), timeFactorForMilliseconds,
- new ArrayList<>());
+ Instant.now(), new LastAccessHolder(Instant.EPOCH), new ArrayList<>());
this.mutableLastAccessTime.lastAccessTime = createTime();
}
@@ -227,7 +218,7 @@ public record ElementAttributes(
public Duration getTimeToLive()
{
final Instant now = Instant.now();
- return Duration.between(now, createTime().plusMillis(MaxLife() * timeFactorForMilliseconds()));
+ return Duration.between(now, createTime().plus(MaxLife()));
}
/**
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
index 43ffeee9..53a98bcd 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
@@ -64,7 +64,7 @@ public interface IElementAttributes extends Serializable
* Gets the idleTime attribute of the IAttributes object
* @return The idleTime value
*/
- long MaxIdleTime();
+ Duration MaxIdleTime();
/**
* This turns off expiration if it is true.
@@ -104,20 +104,14 @@ public interface IElementAttributes extends Serializable
Instant lastAccessTime();
/**
- * Sets the MaxLife attribute of the IAttributes object. How many seconds it can live after
+ * Sets the MaxLife attribute of the IAttributes object. How long it can live after
* creation.
* <p>
* If this is exceeded the element will not be returned, instead it will be removed. It will be
* removed on retrieval, or removed actively if the memory shrinker is turned on.
* @return The MaxLife value
*/
- long MaxLife();
-
- /**
- * Get the time factor to convert durations to milliseconds
- * @return The time factor to convert durations to milliseconds
- */
- long timeFactorForMilliseconds();
+ Duration MaxLife();
/**
* Sets the LastAccessTime as now of the IElementAttributes object
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
index 2d419f33..9e776c3a 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
@@ -20,6 +20,7 @@ package org.apache.commons.jcs4.engine.control;
*/
import java.io.IOException;
+import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
@@ -998,25 +999,24 @@ public class CompositeCache<K, V>
if (!attributes.IsEternal())
{
// Remove if maxLife exceeded
- final long maxLife = attributes.MaxLife();
+ final Duration maxLife = attributes.MaxLife();
final Instant createTime = attributes.createTime();
- final long timeFactorForMilliseconds = attributes.timeFactorForMilliseconds();
- if (maxLife != -1 && timestamp.isAfter(createTime.plusMillis(maxLife * timeFactorForMilliseconds)))
+ if (!maxLife.isNegative() && timestamp.isAfter(createTime.plus(maxLife)))
{
log.debug("Exceeded maxLife: {0}", element::key);
handleElementEvent(element, eventMaxlife);
return true;
}
- final long idleTime = attributes.MaxIdleTime();
+ final Duration idleTime = attributes.MaxIdleTime();
final Instant lastAccessTime = attributes.lastAccessTime();
// Remove if maxIdleTime exceeded
// If you have a 0 size memory cache, then the last access will
// not get updated.
// you will need to set the idle time to -1.
- if (idleTime != -1 && timestamp.isAfter(lastAccessTime.plusMillis(idleTime * timeFactorForMilliseconds)))
+ if (!idleTime.isNegative() && timestamp.isAfter(lastAccessTime.plus(idleTime)))
{
log.debug("Exceeded maxIdle: {0}", element::key);
diff --git a/commons-jcs4-core/src/test/conf/cache.ccf b/commons-jcs4-core/src/test/conf/cache.ccf
index db7bf102..e5b05e2e 100644
--- a/commons-jcs4-core/src/test/conf/cache.ccf
+++ b/commons-jcs4-core/src/test/conf/cache.ccf
@@ -23,8 +23,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true
diff --git a/commons-jcs4-core/src/test/conf/remote.cache.ccf b/commons-jcs4-core/src/test/conf/remote.cache.ccf
index cd10bde6..8f40b2b9 100644
--- a/commons-jcs4-core/src/test/conf/remote.cache.ccf
+++ b/commons-jcs4-core/src/test/conf/remote.cache.ccf
@@ -33,8 +33,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=7000
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT1h56m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
index 8539e6fb..dd0f4bc1 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
@@ -114,7 +114,7 @@ class CacheAccessUnitTest
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
.withMemoryCacheNameAndMaxObjects(memoryCacheClassName, maxMemorySize);
- final long maxLife = 9876;
+ final Duration maxLife = Duration.ofSeconds(9876);
final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
final CacheAccess<String, Integer> access = JCS.getInstance( "testGetMatching_Normal", cattr, attr );
@@ -167,7 +167,7 @@ class CacheAccessUnitTest
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
.withMemoryCacheNameAndMaxObjects(memoryCacheClassName, maxMemorySize);
- final long maxLife = 9876;
+ final Duration maxLife = Duration.ofSeconds(9876);
final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
final CacheAccess<String, Integer> access = JCS.getInstance( "testGetMatching_Normal", cattr, attr );
@@ -331,7 +331,7 @@ class CacheAccessUnitTest
final CompositeCacheAttributes ca = TestCompositeCacheAttributes
.withMaxMemoryIdleTime(maxIdleTime);
- final long maxLife = 9876;
+ final Duration maxLife = Duration.ofSeconds(9876);
final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
final CacheAccess<String, String> access = JCS.getInstance( "testRegionDefinitonWithAttributes", ca, attr );
@@ -352,7 +352,7 @@ class CacheAccessUnitTest
final CacheAccess<String, String> access = JCS.getInstance( "test" );
assertNotNull( access, "We should have an access class" );
- final long maxLife = 9876;
+ final Duration maxLife = Duration.ofSeconds(9876);
final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
access.setDefaultElementAttributes( attr );
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
index 16c700b9..a123a8f7 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
@@ -23,6 +23,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
+import java.time.Duration;
+
import org.apache.commons.jcs4.engine.CacheElementSerialized;
import org.apache.commons.jcs4.engine.ElementAttributes;
import org.apache.commons.jcs4.engine.TestElementAttributes;
@@ -60,7 +62,8 @@ class RemoteCacheListenerUnitTest
final String cacheName = "testName";
final String key = "key";
final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
- final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(34);
+ final ElementAttributes attr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(34));
final IElementSerializer elementSerializer = new StandardSerializer();
@@ -103,7 +106,8 @@ class RemoteCacheListenerUnitTest
final String cacheName = "testName";
final String key = "key";
final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
- final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(34);
+ final ElementAttributes attr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(34));
final IElementSerializer elementSerializer = new StandardSerializer();
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
index 37e5bf39..350ba03a 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
@@ -1,7 +1,5 @@
package org.apache.commons.jcs4.engine;
-import java.time.Instant;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -21,6 +19,8 @@ import java.time.Instant;
* under the License.
*/
+import java.time.Duration;
+import java.time.Instant;
import java.util.ArrayList;
import org.apache.commons.jcs4.engine.ElementAttributes.LastAccessHolder;
@@ -35,7 +35,7 @@ public class TestElementAttributes
*
* @param maxLife The new MaxLife value
*/
- public static ElementAttributes withEternalFalseAndMaxLife(long maxLife)
+ public static ElementAttributes withEternalFalseAndMaxLife(Duration maxLife)
{
ElementAttributes element = new ElementAttributes(
ElementAttributes.defaults().IsSpool(),
@@ -46,7 +46,6 @@ public class TestElementAttributes
ElementAttributes.defaults().MaxIdleTime(),
Instant.now(),
new LastAccessHolder(Instant.EPOCH),
- ElementAttributes.defaults().timeFactorForMilliseconds(),
new ArrayList<>());
element.mutableLastAccessTime().lastAccessTime = element.createTime();
@@ -59,7 +58,7 @@ public class TestElementAttributes
* @param maxLife The new MaxLife value
* @param maxIdleTime The new MaxIdleTime value
*/
- public static ElementAttributes withEternalFalseAndMaxLifeAndMaxIdleTime(long maxLife, long maxIdleTime)
+ public static ElementAttributes withEternalFalseAndMaxLifeAndMaxIdleTime(Duration maxLife, Duration maxIdleTime)
{
ElementAttributes element = new ElementAttributes(
ElementAttributes.defaults().IsSpool(),
@@ -70,7 +69,6 @@ public class TestElementAttributes
maxIdleTime,
Instant.now(),
new LastAccessHolder(Instant.EPOCH),
- ElementAttributes.defaults().timeFactorForMilliseconds(),
new ArrayList<>());
element.mutableLastAccessTime().lastAccessTime = element.createTime();
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
index b3fe61e5..46556fa5 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
@@ -206,7 +206,7 @@ class SimpleEventHandlingUnitTest
}
// wait a bit for the items to expire
- Thread.sleep(attributes.MaxIdleTime() * 1000 + 100);
+ Thread.sleep(attributes.MaxIdleTime().toMillis() + 100);
for ( int i = 0; i < 200; i++ )
{
@@ -244,7 +244,7 @@ class SimpleEventHandlingUnitTest
}
// wait a bit for the items to expire
- Thread.sleep(attributes.MaxLife() * 1000 + 100);
+ Thread.sleep(attributes.MaxLife().toMillis() + 100);
for ( int i = 0; i < 200; i++ )
{
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
index 3005ee46..c0a9dbe9 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
@@ -66,7 +66,7 @@ class ShrinkerThreadUnitTest
final String value = "value";
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
- TestElementAttributes.withEternalFalseAndMaxLife(1));
+ TestElementAttributes.withEternalFalseAndMaxLife(Duration.ofSeconds(1)));
Instant now = Instant.now();
// add two seconds
@@ -101,7 +101,8 @@ class ShrinkerThreadUnitTest
final String value = "value";
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
- TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(100, 1));
+ TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(
+ Duration.ofSeconds(100), Duration.ofSeconds(1)));
Instant now = Instant.now();
// add two seconds
@@ -136,7 +137,7 @@ class ShrinkerThreadUnitTest
final String value = "value";
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
- TestElementAttributes.withEternalFalseAndMaxLife(1));
+ TestElementAttributes.withEternalFalseAndMaxLife(Duration.ofSeconds(1)));
Instant now = Instant.now();
// subtract two seconds
@@ -171,7 +172,8 @@ class ShrinkerThreadUnitTest
final String value = "value";
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
- TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(100, 1));
+ TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(
+ Duration.ofSeconds(100), Duration.ofSeconds(1)));
Instant now = Instant.now();
// subtract two seconds
@@ -209,7 +211,8 @@ class ShrinkerThreadUnitTest
final String key = "key";
final String value = "value";
- final ElementAttributes elementAttr = TestElementAttributes.withEternalFalseAndMaxLife(1);
+ final ElementAttributes elementAttr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(1));
final ICacheElement<String, String> element = new CacheElement<>("testRegion",
key, value, elementAttr);
memory.update( element );
@@ -256,7 +259,8 @@ class ShrinkerThreadUnitTest
final String key = "key" + i;
final String value = "value";
- final ElementAttributes elementAttr = TestElementAttributes.withEternalFalseAndMaxLife(1);
+ final ElementAttributes elementAttr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(1));
final ICacheElement<String, String> element = new CacheElement<>( "testRegion",
key, value, elementAttr);
memory.update( element );
@@ -306,7 +310,8 @@ class ShrinkerThreadUnitTest
final String key = "key" + i;
final String value = "value";
- final ElementAttributes elementAttr = TestElementAttributes.withEternalFalseAndMaxLife(1);
+ final ElementAttributes elementAttr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(1));
final ICacheElement<String, String> element = new CacheElement<>( "testRegion",
key, value, elementAttr);
elementAttr.addElementEventHandler( handler );
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
index 9706a59a..84070d2d 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
@@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
+import java.time.Duration;
import org.apache.commons.jcs4.engine.CacheElement;
import org.apache.commons.jcs4.engine.ElementAttributes;
@@ -54,7 +55,8 @@ class SerializationConversionUtilUnitTest
final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
final IElementSerializer elementSerializer = new StandardSerializer();
- final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(34);
+ final ElementAttributes attr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(34));
final ICacheElement<String, String> before = new CacheElement<>(cacheName, key,
value, attr);
@@ -135,7 +137,8 @@ class SerializationConversionUtilUnitTest
final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
final IElementSerializer elementSerializer = null; // new StandardSerializer();
- final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(34);
+ final ElementAttributes attr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(34));
final ICacheElement<String, String> before = new CacheElement<>(cacheName, key,
value, attr);
@@ -169,7 +172,8 @@ class SerializationConversionUtilUnitTest
final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
final IElementSerializer elementSerializer = new StandardSerializer();
- final ElementAttributes attr = TestElementAttributes.withEternalFalseAndMaxLife(34);
+ final ElementAttributes attr = TestElementAttributes
+ .withEternalFalseAndMaxLife(Duration.ofSeconds(34));
final ICacheElement<String, String> before = new CacheElement<>(cacheName, key,
value, attr);
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
index a4b04d4b..8bc7e566 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
@@ -23,8 +23,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
jcs.region.noRemoveAll=HSQL_NORA
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
index c0994be5..544ee1e5 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
@@ -23,8 +23,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
jcs.region.noRemoveAll=HSQL_NORA
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
index 6abbf934..ec701a3d 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
@@ -22,8 +22,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
# #############################################################
# ################# AUXILIARY CACHES AVAILABLE ################
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
index 54151af1..828904fa 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
@@ -23,8 +23,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
# #############################################################
# ################# AUXILIARY CACHES AVAILABLE ################
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
index dbae3be2..c95ac430 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
@@ -22,8 +22,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
# #############################################################
# ################# CONFIGURED REGIONS ########################
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
index ea64be8f..cd9dc5bc 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
@@ -22,22 +22,22 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
# #############################################################
# ################# REGIONS ###################################
jcs.region.expire1Second=JDBC
jcs.region.expire1Second.cacheattributes.MaxObjects=0
-jcs.region.expire1Second.elementattributes.MaxLife=1
+jcs.region.expire1Second.elementattributes.MaxLife=PT1s
jcs.region.expire100Second=JDBC
jcs.region.expire100Second.cacheattributes.MaxObjects=0
-jcs.region.expire100Second.elementattributes.MaxLife=100
+jcs.region.expire100Second.elementattributes.MaxLife=PT1m40s
jcs.region.eternal=JDBC
jcs.region.eternal.cacheattributes.MaxObjects=0
-jcs.region.eternal.elementattributes.MaxLife=1
+jcs.region.eternal.elementattributes.MaxLife=PT1s
jcs.region.eternal.elementattributes.IsEternal=true
# #############################################################
diff --git a/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
index 7fb0e72c..9dc30652 100644
--- a/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestMRUCache.ccf
@@ -24,8 +24,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1s
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=600
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT10m
+jcs.default.elementattributes.MaxIdleTime=PT30m
# Region defined that uses the MRU
jcs.region.mruDefined=
diff --git a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
index 2ee668fb..478fec76 100644
--- a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
@@ -25,8 +25,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
# #############################################################
# ################# AUXILIARY CACHES AVAILABLE ################
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
index 81b344b6..54e0f78c 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf
@@ -23,8 +23,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
jcs.auxiliary.RC=org.apache.commons.jcs4.auxiliary.remote.RemoteCacheFactory
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
index 0e0ca49c..fb43c2fc 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteHttpCache.ccf
@@ -23,8 +23,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
## The Http Remote Cache Client
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
index f62ed072..66076f68 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoteServer.ccf
@@ -34,5 +34,5 @@ jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=7000
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT1h56m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
diff --git a/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf b/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf
index 61dca71b..586e553c 100644
--- a/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestSimpleEventHandling.ccf
@@ -36,13 +36,13 @@ jcs.region.DiskButNotAllowed.elementattributes.IsSpool=false
jcs.region.Maxlife=
jcs.region.Maxlife.cacheattributes.MaxObjects=200
jcs.region.Maxlife.elementattributes.IsEternal=false
-jcs.region.Maxlife.elementattributes.MaxLife=1
+jcs.region.Maxlife.elementattributes.MaxLife=PT1s
jcs.region.Idletime=
jcs.region.Idletime.cacheattributes.MaxObjects=200
jcs.region.Idletime.elementattributes.IsEternal=false
-jcs.region.Idletime.elementattributes.MaxLife=300
-jcs.region.Idletime.elementattributes.MaxIdleTime=1
+jcs.region.Idletime.elementattributes.MaxLife=PT5m
+jcs.region.Idletime.elementattributes.MaxIdleTime=PT1s
# #### AUXILIARY CACHES
# Indexed Disk Cache
diff --git a/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf b/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf
index c493f3bc..10f67e6a 100644
--- a/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestSoftReferenceCache.ccf
@@ -21,8 +21,8 @@ jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memor
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=600
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT10m
+jcs.default.elementattributes.MaxIdleTime=PT30m
# Region defined that uses the Soft Reference
jcs.region.srDefined=
diff --git a/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf b/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
index 3d13b088..2eb7331d 100644
--- a/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestZeroSizeCache.ccf
@@ -23,5 +23,5 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1s
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=600
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT10m
+jcs.default.elementattributes.MaxIdleTime=PT30m
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java
index 4fbc36da..82e1efb5 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java
@@ -698,20 +698,20 @@ public class JCSCache<K, V> implements Cache<K, V>
final K jcsKey = storeByValue ? copy(serializer, manager.getClassLoader(), key) : key;
IElementAttributes attributes = oldElt != null ? oldElt.elementAttributes() : delegate.getElementAttributes();
- if (created && duration != null) { // set maxLife
- final long timeFactorForMilliseconds = 1;
+ if (created && duration != null)
+ { // set maxLife
final boolean eternal = duration.isEternal();
- long maxIdleTime = attributes.MaxIdleTime();
- long maxLife = attributes.MaxLife();
+ java.time.Duration maxIdleTime = attributes.MaxIdleTime();
+ java.time.Duration maxLife = attributes.MaxLife();
if (!eternal)
{
if (duration == expiryPolicy.getExpiryForAccess())
{
- maxIdleTime = duration.getTimeUnit().toMillis(duration.getDurationAmount());
+ maxIdleTime = java.time.Duration.of(duration.getDurationAmount(), duration.getTimeUnit().toChronoUnit());
}
else
{
- maxLife = duration.getTimeUnit().toMillis(duration.getDurationAmount());
+ maxLife = java.time.Duration.of(duration.getDurationAmount(), duration.getTimeUnit().toChronoUnit());
}
}
attributes = new ElementAttributes(
@@ -720,8 +720,7 @@ public class JCSCache<K, V> implements Cache<K, V>
attributes.IsRemote(),
eternal,
maxLife,
- maxIdleTime,
- timeFactorForMilliseconds);
+ maxIdleTime);
}
final ICacheElement<K, V> element = updateElement(
jcsKey, value, created ? null : duration, attributes);
@@ -978,8 +977,7 @@ public class JCSCache<K, V> implements Cache<K, V>
attrs.IsRemote(),
duration.isEternal(),
attrs.MaxLife(),
- attrs.MaxIdleTime(),
- 1)
+ attrs.MaxIdleTime())
: attrs;
return new CacheElement<>(name, key, v, newAttributes);
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
index 317ee426..4db7e76c 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
@@ -83,8 +83,8 @@ public class JCSCachingManager implements CacheManager
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
- jcs.default.elementattributes.MaxLife=700
- jcs.default.elementattributes.MaxIdleTime=1800
+ jcs.default.elementattributes.MaxLife=PT11m40s
+ jcs.default.elementattributes.MaxIdleTime=PT30m
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true
diff --git a/src/site/xdoc/ElementAttributes.xml b/src/site/xdoc/ElementAttributes.xml
index 3022df10..448aa2c5 100644
--- a/src/site/xdoc/ElementAttributes.xml
+++ b/src/site/xdoc/ElementAttributes.xml
@@ -53,8 +53,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
]]>
</source>
<p>
@@ -110,7 +110,7 @@ jcs.default.elementattributes.MaxIdleTime=1800
for more information on the disk cache settings).
</td>
<td>N</td>
- <td>-1 (unlimited)</td>
+ <td>PT-0.001s (unlimited)</td>
</tr>
<tr>
<td>MaxIdleTime</td>
@@ -119,7 +119,7 @@ jcs.default.elementattributes.MaxIdleTime=1800
without being accessed by setting the
<code>MaxIdleTime</code>
parameter. This is different than the
- <code>MaxMemoryIdleTimeSeconds</code>
+ <code>MaxMemoryIdleTime</code>
parameter, which just specifies how long an object
can be in memory before it is subjected to removal
or being spooled to a disk cache if it is available.
@@ -129,7 +129,7 @@ jcs.default.elementattributes.MaxIdleTime=1800
retrieved from disk, if you have a memory size of 0.
</td>
<td>N</td>
- <td>-1 (unlimited)</td>
+ <td>PT-0.001s (unlimited)</td>
</tr>
<tr>
<td>IsSpool</td>
@@ -188,9 +188,8 @@ jcs.default.elementattributes.MaxIdleTime=1800
defaultAttributes.isLateral(),
defaultAttributes.isRemote(),
/* isEternal */ false,
- /* maxLife */ 1800,
- /* maxIdleTime */ 900,
- defaultAttributes.timeFactorForMilliseconds());
+ /* maxLife */ Duration.ofSeconds(1800),
+ /* maxIdleTime */ Duration.ofSeconds(900));
jcs.put( "key", "data", attributes );
]]>
@@ -214,9 +213,8 @@ jcs.default.elementattributes.MaxIdleTime=1800
defaultAttributes.isLateral(),
defaultAttributes.isRemote(),
/* isEternal */ false,
- /* maxLife */ 1800,
- /* maxIdleTime */ 900,
- defaultAttributes.timeFactorForMilliseconds());
+ /* maxLife */ Duration.ofSeconds(1800),
+ /* maxIdleTime */ Duration.ofSeconds(900));
jcs.setDefaultElementAttributes( attributes );
]]>
diff --git a/src/site/xdoc/IndexedDiskAuxCache.xml b/src/site/xdoc/IndexedDiskAuxCache.xml
index 38996077..49aecf86 100644
--- a/src/site/xdoc/IndexedDiskAuxCache.xml
+++ b/src/site/xdoc/IndexedDiskAuxCache.xml
@@ -241,8 +241,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
##############################################################
################## AUXILIARY CACHES AVAILABLE ################
diff --git a/src/site/xdoc/JDBCDiskCache.xml b/src/site/xdoc/JDBCDiskCache.xml
index c796191f..9d24961e 100644
--- a/src/site/xdoc/JDBCDiskCache.xml
+++ b/src/site/xdoc/JDBCDiskCache.xml
@@ -43,8 +43,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT2h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=14400
-jcs.default.elementattributes.MaxIdleTime=14400
+jcs.default.elementattributes.MaxLife=PT4h
+jcs.default.elementattributes.MaxIdleTime=PT4h
##############################################################
################## CACHE REGIONS AVAILABLE ###################
@@ -62,7 +62,7 @@ jcs.auxiliary.MYSQL.attributes.testBeforeInsert=false
jcs.auxiliary.MYSQL.attributes.maxActive=100
jcs.auxiliary.MYSQL.attributes.MaxPurgatorySize=10000000
jcs.auxiliary.MYSQL.attributes.UseDiskShrinker=true
-jcs.auxiliary.MYSQL.attributes.ShrinkerInterval=1800
+jcs.auxiliary.MYSQL.attributes.ShrinkerInterval=PT30m
jcs.auxiliary.MYSQL.attributes.allowRemoveAll=false
jcs.auxiliary.MYSQL.attributes.EventQueueType=POOLED
jcs.auxiliary.MYSQL.attributes.EventQueuePoolName=disk_cache_event_queue
@@ -92,8 +92,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
# #############################################################
# ################# CONFIGURED REGIONS ########################
@@ -157,8 +157,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT11m40s
+jcs.default.elementattributes.MaxIdleTime=PT30m
# #############################################################
# ################# CONFIGURED REGIONS ########################
diff --git a/src/site/xdoc/RegionProperties.xml b/src/site/xdoc/RegionProperties.xml
index 8f628af2..cb3743dc 100644
--- a/src/site/xdoc/RegionProperties.xml
+++ b/src/site/xdoc/RegionProperties.xml
@@ -262,7 +262,7 @@ jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=700
+jcs.default.elementattributes.MaxLife=PT11m40s
# optional region "testCache1" specific configuration settings (only those that differ from default)
jcs.region.testCache1=
@@ -270,7 +270,7 @@ jcs.region.testCache1.cacheattributes.MaxObjects=123456
jcs.region.testCache1.cacheattributes.ShrinkerInterval=PT30s
jcs.region.testCache1.cacheattributes.MaxMemoryIdleTime=PT5m
jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=100
-jcs.region.testCache1.elementattributes.MaxLife=60000
+jcs.region.testCache1.elementattributes.MaxLife=PT16h40m
]]>
</source>
</subsection>
diff --git a/src/site/xdoc/UsingJCSBasicWeb.xml b/src/site/xdoc/UsingJCSBasicWeb.xml
index a831b7cc..2a8fa57e 100644
--- a/src/site/xdoc/UsingJCSBasicWeb.xml
+++ b/src/site/xdoc/UsingJCSBasicWeb.xml
@@ -364,8 +364,8 @@ public class BookVObjManager
jcs.default=DC,RFailover
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=3600
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT1h
+jcs.default.elementattributes.MaxIdleTime=PT30m
# CACHE REGIONS AVAILABLE
@@ -374,8 +374,8 @@ jcs.default.elementattributes.MaxIdleTime=1800
jcs.region.bookCache=DC,RFailover
jcs.region.bookCache.cacheattributes.MaxObjects=1200
jcs.region.bookCache.elementattributes.IsEternal=false
-jcs.region.bookCache.elementattributes.MaxLife=7200
-jcs.region.bookCache.elementattributes.MaxIdleTime=1800
+jcs.region.bookCache.elementattributes.MaxLife=PT2h
+jcs.region.bookCache.elementattributes.MaxIdleTime=PT30m
jcs.region.bookCache.elementattributes.IsSpool=true
jcs.region.bookCache.elementattributes.IsRemote=true
jcs.region.bookCache.elementattributes.IsLateral=true
diff --git a/src/site/xdoc/getting_started/intro.xml b/src/site/xdoc/getting_started/intro.xml
index 49dfbfa4..5fb5248e 100644
--- a/src/site/xdoc/getting_started/intro.xml
+++ b/src/site/xdoc/getting_started/intro.xml
@@ -153,8 +153,8 @@ jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
jcs.default.elementattributes.IsEternal=false
-jcs.default.elementattributes.MaxLife=21600
-jcs.default.elementattributes.MaxIdleTime=1800
+jcs.default.elementattributes.MaxLife=PT6h
+jcs.default.elementattributes.MaxIdleTime=PT30m
# PRE-DEFINED CACHE REGIONS
jcs.region.testCache1=DC
(commons-jcs) 10/11: Fix scope
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 69189732a2a537274bb8163ddf9748a3378b4624
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Thu Mar 19 10:13:05 2026 +0100
Fix scope
---
.../org/apache/commons/jcs4/engine/behavior/IElementAttributes.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
index 53a98bcd..81a1b6cd 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
@@ -124,5 +124,5 @@ public interface IElementAttributes extends Serializable
* This is the (max life + create time) - current time.
* @return The TimeToLive value
*/
- public Duration getTimeToLive();
+ Duration getTimeToLive();
}
(commons-jcs) 01/11: Fix documentation and case-sensitive naming of configuration properties
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 8d0bcdf0a9b5969c49e276a43e848ae881bc8681
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Tue Mar 17 18:05:25 2026 +0100
Fix documentation and case-sensitive naming of configuration properties
---
.../apache/commons/jcs4/admin/JCSAdminBean.java | 6 +-
.../jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java | 8 +-
.../jcs4/engine/CompositeCacheAttributes.java | 63 ++++-----
.../commons/jcs4/engine/ElementAttributes.java | 40 +++---
.../engine/behavior/ICompositeCacheAttributes.java | 40 ++----
.../jcs4/engine/behavior/IElementAttributes.java | 16 +--
.../jcs4/engine/control/CompositeCache.java | 33 +++--
.../AbstractDoubleLinkedListMemoryCache.java | 4 +-
.../jcs4/engine/memory/AbstractMemoryCache.java | 2 +-
.../jcs4/engine/memory/lru/LHMLRUMemoryCache.java | 6 +-
.../engine/memory/shrinking/ShrinkerThread.java | 6 +-
.../memory/soft/SoftReferenceMemoryCache.java | 4 +-
.../commons/jcs4/access/CacheAccessUnitTest.java | 10 +-
.../jcs4/access/SystemPropertyUnitTest.java | 4 +-
.../remote/RemoteCacheListenerUnitTest.java | 4 +-
.../jcs4/engine/SystemPropertyUsageUnitTest.java | 4 +-
.../jcs4/engine/TestCompositeCacheAttributes.java | 74 +++++------
.../commons/jcs4/engine/TestElementAttributes.java | 14 +-
.../CompositeCacheConfiguratorUnitTest.java | 2 +-
.../control/CompositeCacheDiskUsageUnitTest.java | 20 +--
.../control/event/SimpleEventHandlingUnitTest.java | 4 +-
.../memory/lru/LHMLRUMemoryCacheUnitTest.java | 16 +--
.../engine/memory/mru/MRUMemoryCacheUnitTest.java | 16 +--
.../memory/shrinking/ShrinkerThreadUnitTest.java | 8 +-
.../soft/SoftReferenceMemoryCacheUnitTest.java | 12 +-
.../SerializationConversionUtilUnitTest.java | 8 +-
.../org/apache/commons/jcs4/jcache/JCSCache.java | 24 ++--
src/site/xdoc/ElementAttributes.xml | 146 +++++++++++++--------
src/site/xdoc/RegionProperties.xml | 19 +++
29 files changed, 311 insertions(+), 302 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java
index 38a00d20..e32a5a60 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java
@@ -144,10 +144,10 @@ public class JCSAdminBean implements JCSJMXBean
final CacheElementInfo elementInfo = new CacheElementInfo(
key.getKey(),
- attributes.isEternal(),
+ attributes.IsEternal(),
format.format(new Date(attributes.createTime())),
- attributes.maxLife(),
- (now - attributes.createTime() - attributes.maxLife() * 1000 ) / -1000);
+ attributes.MaxLife(),
+ (now - attributes.createTime() - attributes.MaxLife() * 1000 ) / -1000);
records.add( elementInfo );
}
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
index 3a0d9708..731b6aa5 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
@@ -427,8 +427,8 @@ public class JDBCDiskCache<K, V>
psInsert.setString( 1, ce.key().toString() );
psInsert.setString( 2, getCacheName() );
psInsert.setBytes( 3, element );
- psInsert.setLong( 4, ce.elementAttributes().maxLife() );
- psInsert.setString( 5, ce.elementAttributes().isEternal() ? "T" : "F" );
+ psInsert.setLong( 4, ce.elementAttributes().MaxLife() );
+ psInsert.setString( 5, ce.elementAttributes().IsEternal() ? "T" : "F" );
final Timestamp createTime = new Timestamp( ce.elementAttributes().createTime() );
psInsert.setTimestamp( 6, createTime );
@@ -436,7 +436,7 @@ public class JDBCDiskCache<K, V>
final long now = System.currentTimeMillis() / 1000;
psInsert.setLong( 7, now );
- final long expireTime = now + ce.elementAttributes().maxLife();
+ final long expireTime = now + ce.elementAttributes().MaxLife();
psInsert.setLong( 8, expireTime );
psInsert.execute();
@@ -483,7 +483,7 @@ public class JDBCDiskCache<K, V>
final long now = System.currentTimeMillis() / 1000;
psUpdate.setLong( 3, now );
- final long expireTime = now + ce.elementAttributes().maxLife();
+ final long expireTime = now + ce.elementAttributes().MaxLife();
psUpdate.setLong( 4, expireTime );
psUpdate.setString( 5, (String) ce.key() );
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
index 83348105..6b5484af 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
@@ -33,34 +33,28 @@ public record CompositeCacheAttributes(
String cacheName,
/** The maximum objects that the memory cache will be allowed to hold. */
- int maxObjects,
-
- /** Allow lateral caches */
- boolean useLateral,
-
- /** Whether we should use a disk cache if it is configured. */
- boolean useDisk,
+ int MaxObjects,
/** Whether or not we should run the memory shrinker thread. */
- boolean useMemoryShrinker,
+ boolean UseMemoryShrinker,
/** ShrinkerIntervalSeconds */
- long shrinkerIntervalSeconds,
+ long ShrinkerIntervalSeconds,
/** The maximum number the shrinker will spool to disk per run. */
- int maxSpoolPerRun,
+ int MaxSpoolPerRun,
/** MaxMemoryIdleTimeSeconds */
- long maxMemoryIdleTimeSeconds,
+ long MaxMemoryIdleTimeSeconds,
/** The name of the memory cache implementation class. */
- String memoryCacheName,
+ String MemoryCacheName,
- /** Set via DISK_USAGE_PATTERN_NAME */
- DiskUsagePattern diskUsagePattern,
+ /** Set via DISK_USAGE_PATTERN */
+ DiskUsagePatternEnum DiskUsagePattern,
/** How many to spool to disk at a time. */
- int spoolChunkSize
+ int SpoolChunkSize
) implements ICompositeCacheAttributes
{
/** Don't change */
@@ -69,12 +63,6 @@ public record CompositeCacheAttributes(
/** Default max objects value */
private static final int DEFAULT_MAX_OBJECTS = 100;
- /** Default lateral switch */
- private static final boolean DEFAULT_USE_LATERAL = true;
-
- /** Default disk switch */
- private static final boolean DEFAULT_USE_DISK = true;
-
/** Default shrinker setting */
private static final boolean DEFAULT_USE_SHRINKER = false;
@@ -97,14 +85,12 @@ public record CompositeCacheAttributes(
private static final CompositeCacheAttributes DEFAULT = new CompositeCacheAttributes(
null,
DEFAULT_MAX_OBJECTS,
- DEFAULT_USE_LATERAL,
- DEFAULT_USE_DISK,
DEFAULT_USE_SHRINKER,
DEFAULT_SHRINKER_INTERVAL_SECONDS,
DEFAULT_MAX_SPOOL_PER_RUN,
DEFAULT_MAX_MEMORY_IDLE_TIME_SECONDS,
DEFAULT_MEMORY_CACHE_NAME,
- DiskUsagePattern.SWAP,
+ DiskUsagePatternEnum.SWAP,
DEFAULT_CHUNK_SIZE
);
@@ -125,16 +111,14 @@ public record CompositeCacheAttributes(
public CompositeCacheAttributes withCacheName(String s)
{
return new CompositeCacheAttributes(s,
- maxObjects(),
- useLateral(),
- useDisk(),
- useMemoryShrinker(),
- shrinkerIntervalSeconds(),
- maxSpoolPerRun(),
- maxMemoryIdleTimeSeconds(),
- memoryCacheName(),
- diskUsagePattern(),
- spoolChunkSize());
+ MaxObjects(),
+ UseMemoryShrinker(),
+ ShrinkerIntervalSeconds(),
+ MaxSpoolPerRun(),
+ MaxMemoryIdleTimeSeconds(),
+ MemoryCacheName(),
+ DiskUsagePattern(),
+ SpoolChunkSize());
}
/**
@@ -147,13 +131,10 @@ public record CompositeCacheAttributes(
{
final StringBuilder dump = new StringBuilder();
- dump.append( "[ " );
- dump.append( "useLateral = " ).append( useLateral );
- dump.append( ", useDisk = " ).append( useDisk );
- dump.append( ", maxObjects = " ).append( maxObjects );
- dump.append( ", maxSpoolPerRun = " ).append( maxSpoolPerRun );
- dump.append( ", diskUsagePattern = " ).append( diskUsagePattern );
- dump.append( ", spoolChunkSize = " ).append( spoolChunkSize );
+ dump.append( "[ MaxObjects = " ).append( MaxObjects() );
+ dump.append( ", MaxSpoolPerRun = " ).append( MaxSpoolPerRun() );
+ dump.append( ", DiskUsagePattern = " ).append( DiskUsagePattern() );
+ dump.append( ", SpoolChunkSize = " ).append( SpoolChunkSize() );
dump.append( " ]" );
return dump.toString();
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
index ecb05138..d593dc3e 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
@@ -39,28 +39,28 @@ import org.apache.commons.jcs4.engine.control.event.behavior.IElementEventHandle
*/
public record ElementAttributes(
/** Can this item be flushed to disk */
- boolean isSpool,
+ boolean IsSpool,
/** Is this item laterally distributable */
- boolean isLateral,
+ boolean IsLateral,
/** Can this item be sent to the remote cache */
- boolean isRemote,
+ boolean IsRemote,
/**
* You can turn off expiration by setting this to true. This causes the cache to bypass both max
* life and idle time expiration.
*/
- boolean isEternal,
+ boolean IsEternal,
- /** Max life seconds */
- long maxLife,
+ /** Max life */
+ long MaxLife,
/**
* The maximum time an entry can be idle. Setting this to -1 causes the idle time check to be
* ignored.
*/
- long maxIdleTime,
+ long MaxIdleTime,
/** The creation time. This is used to enforce the max life. */
long createTime,
@@ -134,12 +134,12 @@ public record ElementAttributes(
*/
public ElementAttributes(IElementAttributes from)
{
- this(from.isSpool(),
- from.isLateral(),
- from.isRemote(),
- from.isEternal(),
- from.maxLife(),
- from.maxIdleTime(),
+ this(from.IsSpool(),
+ from.IsLateral(),
+ from.IsRemote(),
+ from.IsEternal(),
+ from.MaxLife(),
+ from.MaxIdleTime(),
System.currentTimeMillis(),
new AtomicLong(from.lastAccessTime()),
from.timeFactorForMilliseconds(),
@@ -210,7 +210,7 @@ public record ElementAttributes(
private long getTimeToLiveSeconds()
{
final long now = System.currentTimeMillis();
- return ( createTime() + maxLife() * timeFactorForMilliseconds() - now ) / 1000;
+ return ( createTime() + MaxLife() * timeFactorForMilliseconds() - now ) / 1000;
}
/**
@@ -223,12 +223,12 @@ public record ElementAttributes(
{
final StringBuilder dump = new StringBuilder();
- dump.append( "[ isLateral = " ).append( isLateral() );
- dump.append( ", isSpool = " ).append( isSpool() );
- dump.append( ", isRemote = " ).append( isRemote() );
- dump.append( ", isEternal = " ).append( isEternal() );
- dump.append( ", MaxLifeSeconds = " ).append( maxLife() );
- dump.append( ", MaxIdleTime = " ).append( maxIdleTime() );
+ dump.append( "[ isLateral = " ).append( IsLateral() );
+ dump.append( ", isSpool = " ).append( IsSpool() );
+ dump.append( ", isRemote = " ).append( IsRemote() );
+ dump.append( ", isEternal = " ).append( IsEternal() );
+ dump.append( ", MaxLifeSeconds = " ).append( MaxLife() );
+ dump.append( ", MaxIdleTime = " ).append( MaxIdleTime() );
dump.append( ", CreateTime = " ).append( createTime() );
dump.append( ", LastAccessTime = " ).append( lastAccessTime() );
dump.append( ", getTimeToLiveSeconds() = " ).append(getTimeToLiveSeconds());
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
index ea955d4e..e7727720 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/ICompositeCacheAttributes.java
@@ -27,7 +27,7 @@ import java.io.Serializable;
public interface ICompositeCacheAttributes
extends Serializable
{
- enum DiskUsagePattern
+ enum DiskUsagePatternEnum
{
/** Items will only go to disk when the memory limit is reached. This is the default. */
SWAP,
@@ -47,9 +47,9 @@ public interface ICompositeCacheAttributes
String cacheName();
/**
- * @return the diskUsagePattern.
+ * @return the DiskUsagePattern.
*/
- DiskUsagePattern diskUsagePattern();
+ DiskUsagePatternEnum DiskUsagePattern();
/**
* If UseMemoryShrinker is true the memory cache should auto-expire elements
@@ -57,30 +57,30 @@ public interface ICompositeCacheAttributes
*
* @return The MaxMemoryIdleTimeSeconds value
*/
- long maxMemoryIdleTimeSeconds();
+ long MaxMemoryIdleTimeSeconds();
/**
* Gets the maxObjects attribute of the ICompositeCacheAttributes object
*
- * @return The maxObjects value
+ * @return The MaxObjects value
*/
- int maxObjects();
+ int MaxObjects();
/**
* If UseMemoryShrinker is true the memory cache should auto-expire elements
* to reclaim space. This gets the maximum number of items to spool per run.
*
- * @return The maxSpoolPerRun value
+ * @return The MaxSpoolPerRun value
*/
- int maxSpoolPerRun();
+ int MaxSpoolPerRun();
/**
* Gets the memoryCacheName attribute of the ICompositeCacheAttributes
* object
*
- * @return The memoryCacheName value
+ * @return The MemoryCacheName value
*/
- String memoryCacheName();
+ String MemoryCacheName();
/**
* If UseMemoryShrinker is true the memory cache should auto-expire elements
@@ -88,35 +88,21 @@ public interface ICompositeCacheAttributes
*
* @return The ShrinkerIntervalSeconds value
*/
- long shrinkerIntervalSeconds();
+ long ShrinkerIntervalSeconds();
/**
* Number to send to disk at time when memory is full.
*
* @return int
*/
- int spoolChunkSize();
-
- /**
- * Gets the useDisk attribute of the ICompositeCacheAttributes object
- *
- * @return The useDisk value
- */
- boolean useDisk();
-
- /**
- * Gets the useLateral attribute of the ICompositeCacheAttributes object
- *
- * @return The useLateral value
- */
- boolean useLateral();
+ int SpoolChunkSize();
/**
* Tests whether the memory cache should perform background memory shrinkage.
*
* @return The UseMemoryShrinker value
*/
- boolean useMemoryShrinker();
+ boolean UseMemoryShrinker();
/**
* Sets the name of the cache, referenced by the appropriate manager.
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
index 5e5af150..317ea27d 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
@@ -62,13 +62,13 @@ public interface IElementAttributes extends Serializable
* Gets the idleTime attribute of the IAttributes object
* @return The idleTime value
*/
- long maxIdleTime();
+ long MaxIdleTime();
/**
* This turns off expiration if it is true.
* @return The IsEternal value
*/
- boolean isEternal();
+ boolean IsEternal();
/**
* Is this item laterally distributable. Can it be sent to auxiliaries of type lateral.
@@ -76,7 +76,7 @@ public interface IElementAttributes extends Serializable
* By default this is true.
* @return The isLateral value
*/
- boolean isLateral();
+ boolean IsLateral();
/**
* Can this item be sent to the remote cache.
@@ -84,7 +84,7 @@ public interface IElementAttributes extends Serializable
* By default this is true.
* @return The isRemote value
*/
- boolean isRemote();
+ boolean IsRemote();
/**
* Can this item be spooled to disk
@@ -92,7 +92,7 @@ public interface IElementAttributes extends Serializable
* By default this is true.
* @return The spoolable value
*/
- boolean isSpool();
+ boolean IsSpool();
/**
* Gets the LastAccess attribute of the IAttributes object.
@@ -102,14 +102,14 @@ public interface IElementAttributes extends Serializable
long lastAccessTime();
/**
- * Sets the maxLife attribute of the IAttributes object. How many seconds it can live after
+ * Sets the MaxLife attribute of the IAttributes object. How many seconds it can live after
* creation.
* <p>
* If this is exceeded the element will not be returned, instead it will be removed. It will be
* removed on retrieval, or removed actively if the memory shrinker is turned on.
- * @return The MaxLifeSeconds value
+ * @return The MaxLife value
*/
- long maxLife();
+ long MaxLife();
/**
* Get the time factor to convert durations to milliseconds
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
index 69062179..7ce1642d 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
@@ -44,7 +44,7 @@ import org.apache.commons.jcs4.engine.CacheStatus;
import org.apache.commons.jcs4.engine.behavior.ICache;
import org.apache.commons.jcs4.engine.behavior.ICacheElement;
import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes;
-import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes.DiskUsagePattern;
+import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes.DiskUsagePatternEnum;
import org.apache.commons.jcs4.engine.behavior.IElementAttributes;
import org.apache.commons.jcs4.engine.behavior.IRequireScheduler;
import org.apache.commons.jcs4.engine.control.event.ElementEvent;
@@ -158,7 +158,7 @@ public class CompositeCache<K, V>
private void copyAuxiliaryRetrievedItemToMemory(final ICacheElement<K, V> element)
throws IOException
{
- if (memCache.getCacheAttributes().maxObjects() > 0)
+ if (memCache.getCacheAttributes().MaxObjects() > 0)
{
memCache.update(element);
}
@@ -181,7 +181,7 @@ public class CompositeCache<K, V>
{
try
{
- final Class<?> c = Class.forName(cattr.memoryCacheName());
+ final Class<?> c = Class.forName(cattr.MemoryCacheName());
@SuppressWarnings("unchecked") // Need cast
final
IMemoryCache<K, V> newInstance =
@@ -994,10 +994,10 @@ public class CompositeCache<K, V>
{
final IElementAttributes attributes = element.elementAttributes();
- if (!attributes.isEternal())
+ if (!attributes.IsEternal())
{
// Remove if maxLifeSeconds exceeded
- final long maxLifeSeconds = attributes.maxLife();
+ final long maxLifeSeconds = attributes.MaxLife();
final long createTime = attributes.createTime();
final long timeFactorForMilliseconds = attributes.timeFactorForMilliseconds();
@@ -1008,7 +1008,7 @@ public class CompositeCache<K, V>
handleElementEvent(element, eventMaxlife);
return true;
}
- final long idleTime = attributes.maxIdleTime();
+ final long idleTime = attributes.MaxIdleTime();
final long lastAccessTime = attributes.lastAccessTime();
// Remove if maxIdleTime exceeded
@@ -1410,10 +1410,10 @@ public class CompositeCache<K, V>
@Override
public void setScheduledExecutorService(final ScheduledExecutorService scheduledExecutor)
{
- if (cacheAttr.useMemoryShrinker())
+ if (cacheAttr.UseMemoryShrinker())
{
future = scheduledExecutor.scheduleAtFixedRate(
- new ShrinkerThread<>(this), 0, cacheAttr.shrinkerIntervalSeconds(),
+ new ShrinkerThread<>(this), 0, cacheAttr.ShrinkerIntervalSeconds(),
TimeUnit.SECONDS);
}
@@ -1435,7 +1435,7 @@ public class CompositeCache<K, V>
public void spoolToDisk(final ICacheElement<K, V> ce)
{
// if the item is not spoolable, return
- if (!ce.elementAttributes().isSpool())
+ if (!ce.elementAttributes().IsSpool())
{
// there is an event defined for this.
handleElementEvent(ce, ElementEventType.SPOOLED_NOT_ALLOWED);
@@ -1451,7 +1451,7 @@ public class CompositeCache<K, V>
{
diskAvailable = true;
- if (cacheAttr.diskUsagePattern() == DiskUsagePattern.SWAP)
+ if (cacheAttr.DiskUsagePattern() == DiskUsagePatternEnum.SWAP)
{
// write the last items to disk.2
try
@@ -1586,9 +1586,9 @@ public class CompositeCache<K, V>
// SEND TO REMOTE STORE
case REMOTE_CACHE:
log.debug("ce.getElementAttributes().getIsRemote() = {0}",
- cacheElement.elementAttributes()::isRemote);
+ cacheElement.elementAttributes()::IsRemote);
- if (cacheElement.elementAttributes().isRemote() && !localOnly)
+ if (cacheElement.elementAttributes().IsRemote() && !localOnly)
{
try
{
@@ -1609,8 +1609,7 @@ public class CompositeCache<K, V>
case LATERAL_CACHE:
// lateral can't do the checking since it is dependent on the
// cache region restrictions
- log.debug("lateralcache in aux list: cattr {0}", cacheAttr::useLateral);
- if (cacheAttr.useLateral() && cacheElement.elementAttributes().isLateral() && !localOnly)
+ if (cacheElement.elementAttributes().IsLateral() && !localOnly)
{
// DISTRIBUTE LATERALLY
// Currently always multicast even if the value is
@@ -1622,10 +1621,8 @@ public class CompositeCache<K, V>
// update disk if the usage pattern permits
case DISK_CACHE:
- log.debug("diskcache in aux list: cattr {0}", cacheAttr::useDisk);
- if (cacheAttr.useDisk()
- && cacheAttr.diskUsagePattern() == DiskUsagePattern.UPDATE
- && cacheElement.elementAttributes().isSpool())
+ if (cacheAttr.DiskUsagePattern() == DiskUsagePatternEnum.UPDATE
+ && cacheElement.elementAttributes().IsSpool())
{
aux.update(cacheElement);
log.debug("updated disk cache for {0}", cacheElement::key);
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractDoubleLinkedListMemoryCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractDoubleLinkedListMemoryCache.java
index 6d669ea3..dba36124 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractDoubleLinkedListMemoryCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractDoubleLinkedListMemoryCache.java
@@ -274,7 +274,7 @@ public abstract class AbstractDoubleLinkedListMemoryCache<K, V> extends Abstract
final int size = map.size();
// If the element limit is reached, we need to spool
- if (size <= getCacheAttributes().maxObjects())
+ if (size <= getCacheAttributes().MaxObjects())
{
return;
}
@@ -286,7 +286,7 @@ public abstract class AbstractDoubleLinkedListMemoryCache<K, V> extends Abstract
log.debug("About to spool to disk cache, map size: {0}, max objects: {1}, "
+ "maximum items to spool: {2}", () -> size,
- getCacheAttributes()::maxObjects,
+ getCacheAttributes()::MaxObjects,
() -> chunkSizeCorrected);
// The spool will put them in a disk event queue, so there is no
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractMemoryCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractMemoryCache.java
index 1639d939..708a4212 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractMemoryCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/AbstractMemoryCache.java
@@ -310,7 +310,7 @@ public abstract class AbstractMemoryCache<K, V>
putCnt = new AtomicLong();
this.cacheAttributes = hub.getCacheAttributes();
- this.chunkSize = cacheAttributes.spoolChunkSize();
+ this.chunkSize = cacheAttributes.SpoolChunkSize();
this.cache = hub;
this.map = createMap();
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCache.java
index fcd3eecb..4d90c189 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCache.java
@@ -51,7 +51,7 @@ public class LHMLRUMemoryCache<K, V>
*/
public LHMSpooler()
{
- super( (int) ( getCacheAttributes().maxObjects() * .5 ), .75F, true );
+ super( (int) ( getCacheAttributes().MaxObjects() * .5 ), .75F, true );
}
/**
@@ -66,12 +66,12 @@ public class LHMLRUMemoryCache<K, V>
{
final ICacheElement<K, V> element = eldest.getValue().getCacheElement();
- if ( size() <= getCacheAttributes().maxObjects() )
+ if ( size() <= getCacheAttributes().MaxObjects() )
{
return false;
}
log.debug( "LHMLRU max size: {0}. Spooling element, key: {1}",
- () -> getCacheAttributes().maxObjects(), element::key);
+ () -> getCacheAttributes().MaxObjects(), element::key);
waterfall( element );
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
index dc2a3d34..d946f406 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
@@ -59,7 +59,7 @@ public class ShrinkerThread<K, V>
{
this.cache = cache;
- final long maxMemoryIdleTimeSeconds = cache.getCacheAttributes().maxMemoryIdleTimeSeconds();
+ final long maxMemoryIdleTimeSeconds = cache.getCacheAttributes().MaxMemoryIdleTimeSeconds();
if ( maxMemoryIdleTimeSeconds < 0 )
{
@@ -70,7 +70,7 @@ public class ShrinkerThread<K, V>
this.maxMemoryIdleTime = maxMemoryIdleTimeSeconds * 1000;
}
- this.maxSpoolPerRun = cache.getCacheAttributes().maxSpoolPerRun();
+ this.maxSpoolPerRun = cache.getCacheAttributes().MaxSpoolPerRun();
if ( this.maxSpoolPerRun != -1 )
{
this.spoolLimit = true;
@@ -133,7 +133,7 @@ public class ShrinkerThread<K, V>
// If the element is not eternal, check if it should be
// removed and remove it if so.
- if ( !attributes.isEternal() )
+ if ( !attributes.IsEternal() )
{
remove = cache.isExpired( cacheElement, now,
ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND,
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCache.java
index 0fb13e23..3a97004b 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCache.java
@@ -39,7 +39,7 @@ import org.apache.commons.jcs4.log.Log;
/**
* A JCS IMemoryCache that has {@link SoftReference} to all its values.
- * This cache does not respect {@link ICompositeCacheAttributes#maxObjects()}
+ * This cache does not respect {@link ICompositeCacheAttributes#MaxObjects()}
* as overflowing is handled by Java GC.
* <p>
* The cache also has strong references to a maximum number of objects given by
@@ -196,7 +196,7 @@ public class SoftReferenceMemoryCache<K, V> extends AbstractMemoryCache<K, V>
*/
private void trimStrongReferences()
{
- final int max = getCacheAttributes().maxObjects();
+ final int max = getCacheAttributes().MaxObjects();
final int startsize = strongReferences.size();
for (int cursize = startsize; cursize > max; cursize--)
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
index 216a486f..85b3abb4 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
@@ -314,7 +314,7 @@ class CacheAccessUnitTest
assertNotNull( access, "We should have an access class" );
final ICompositeCacheAttributes ca2 = access.getCacheAttributes();
- assertEquals( ca.maxMemoryIdleTimeSeconds(), ca2.maxMemoryIdleTimeSeconds(), "Wrong idle time setting." );
+ assertEquals( ca.MaxMemoryIdleTimeSeconds(), ca2.MaxMemoryIdleTimeSeconds(), "Wrong idle time setting." );
}
/**
@@ -337,7 +337,7 @@ class CacheAccessUnitTest
assertNotNull( access, "We should have an access class" );
final ICompositeCacheAttributes ca2 = access.getCacheAttributes();
- assertEquals( ca.maxMemoryIdleTimeSeconds(), ca2.maxMemoryIdleTimeSeconds(), "Wrong idle time setting." );
+ assertEquals( ca.MaxMemoryIdleTimeSeconds(), ca2.MaxMemoryIdleTimeSeconds(), "Wrong idle time setting." );
}
/**
@@ -356,8 +356,8 @@ class CacheAccessUnitTest
access.setDefaultElementAttributes( attr );
- assertEquals( attr.maxLife(), access.getDefaultElementAttributes()
- .maxLife(), "Wrong element attributes." );
+ assertEquals( attr.MaxLife(), access.getDefaultElementAttributes()
+ .MaxLife(), "Wrong element attributes." );
final String key = "mykey";
final String value = "myvalue";
@@ -367,6 +367,6 @@ class CacheAccessUnitTest
final ICacheElement<String, String> element = access.getCacheElement( key );
assertEquals( maxLife, element.elementAttributes()
- .maxLife(), "Wrong max life. Should have the new value." );
+ .MaxLife(), "Wrong max life. Should have the new value." );
}
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java
index c2c4aa28..7d5cbe1c 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java
@@ -71,7 +71,7 @@ class SystemPropertyUnitTest
System.setProperty( "MY_SYSTEM_PROPERTY_MAX_SIZE", String.valueOf( maxMemory ) );
final CacheAccess<String, String> cache = JCS.getInstance( "test1" );
- assertEquals( maxMemory, cache.getCacheAttributes().maxObjects(),
+ assertEquals( maxMemory, cache.getCacheAttributes().MaxObjects(),
"We should have used the system property for the memory size" );
}
@@ -88,7 +88,7 @@ class SystemPropertyUnitTest
System.setProperty( "MY_SYSTEM_PROPERTY_DISK_DIR", "system_set" );
final CacheAccess<String, String> cache = JCS.getInstance( "missing" );
- assertEquals( 100, cache.getCacheAttributes().maxObjects(),
+ assertEquals( 100, cache.getCacheAttributes().MaxObjects(),
"We should have used the default property for the memory size" );
}
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
index 0820ac35..16c700b9 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
@@ -77,8 +77,8 @@ class RemoteCacheListenerUnitTest
assertNotNull( after, "Should have a deserialized object." );
assertEquals( value, after.value(), "Values should be the same." );
- assertEquals( attr.maxLife(), after
- .elementAttributes().maxLife(), "Attributes should be the same." );
+ assertEquals( attr.MaxLife(), after
+ .elementAttributes().MaxLife(), "Attributes should be the same." );
assertEquals( key, after.key(), "Keys should be the same." );
assertEquals( cacheName, after.cacheName(), "Cache name should be the same." );
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/SystemPropertyUsageUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/SystemPropertyUsageUnitTest.java
index f67b1d90..75101129 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/SystemPropertyUsageUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/SystemPropertyUsageUnitTest.java
@@ -78,7 +78,7 @@ class SystemPropertyUsageUnitTest
manager = CompositeCacheManager.getInstance();
- assertEquals( testValue, jcs.getCacheAttributes().maxObjects(), "System property value is not reflected." );
+ assertEquals( testValue, jcs.getCacheAttributes().MaxObjects(), "System property value is not reflected." );
}
/**
@@ -101,7 +101,7 @@ class SystemPropertyUsageUnitTest
final CacheAccess<String, String> jcs = JCS.getInstance( "someCacheNotInFile" );
assertEquals( Integer.parseInt( props.getProperty( JCS_DEFAULT_CACHEATTRIBUTES_MAX_OBJECTS ) ),
- jcs.getCacheAttributes().maxObjects(),
+ jcs.getCacheAttributes().MaxObjects(),
"System property value should not be reflected" );
}
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
index b40b0b3c..4e3ff276 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
@@ -40,15 +40,13 @@ public class TestCompositeCacheAttributes
{
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
maxObjects,
- CompositeCacheAttributes.defaults().useLateral(),
- CompositeCacheAttributes.defaults().useDisk(),
- CompositeCacheAttributes.defaults().useMemoryShrinker(),
- CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
- CompositeCacheAttributes.defaults().maxSpoolPerRun(),
- CompositeCacheAttributes.defaults().maxMemoryIdleTimeSeconds(),
+ CompositeCacheAttributes.defaults().UseMemoryShrinker(),
+ CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
+ CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
memoryCacheName,
- CompositeCacheAttributes.defaults().diskUsagePattern(),
- CompositeCacheAttributes.defaults().spoolChunkSize());
+ CompositeCacheAttributes.defaults().DiskUsagePattern(),
+ CompositeCacheAttributes.defaults().SpoolChunkSize());
}
/**
@@ -62,16 +60,14 @@ public class TestCompositeCacheAttributes
String memoryCacheName, long maxMemoryIdleTimeSeconds, int maxSpoolPerRun)
{
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
- CompositeCacheAttributes.defaults().maxObjects(),
- CompositeCacheAttributes.defaults().useLateral(),
- CompositeCacheAttributes.defaults().useDisk(),
- CompositeCacheAttributes.defaults().useMemoryShrinker(),
- CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().MaxObjects(),
+ CompositeCacheAttributes.defaults().UseMemoryShrinker(),
+ CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
maxSpoolPerRun,
maxMemoryIdleTimeSeconds,
memoryCacheName,
- CompositeCacheAttributes.defaults().diskUsagePattern(),
- CompositeCacheAttributes.defaults().spoolChunkSize());
+ CompositeCacheAttributes.defaults().DiskUsagePattern(),
+ CompositeCacheAttributes.defaults().SpoolChunkSize());
}
/**
@@ -84,14 +80,12 @@ public class TestCompositeCacheAttributes
{
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
maxObjects,
- CompositeCacheAttributes.defaults().useLateral(),
- CompositeCacheAttributes.defaults().useDisk(),
- CompositeCacheAttributes.defaults().useMemoryShrinker(),
- CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
- CompositeCacheAttributes.defaults().maxSpoolPerRun(),
- CompositeCacheAttributes.defaults().maxMemoryIdleTimeSeconds(),
- CompositeCacheAttributes.defaults().memoryCacheName(),
- CompositeCacheAttributes.defaults().diskUsagePattern(),
+ CompositeCacheAttributes.defaults().UseMemoryShrinker(),
+ CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
+ CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
+ CompositeCacheAttributes.defaults().MemoryCacheName(),
+ CompositeCacheAttributes.defaults().DiskUsagePattern(),
spoolChunkSize);
}
@@ -103,16 +97,14 @@ public class TestCompositeCacheAttributes
public static CompositeCacheAttributes withMaxMemoryIdleTimeSeconds(long maxMemoryIdleTimeSeconds)
{
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
- CompositeCacheAttributes.defaults().maxObjects(),
- CompositeCacheAttributes.defaults().useLateral(),
- CompositeCacheAttributes.defaults().useDisk(),
- CompositeCacheAttributes.defaults().useMemoryShrinker(),
- CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
- CompositeCacheAttributes.defaults().maxSpoolPerRun(),
+ CompositeCacheAttributes.defaults().MaxObjects(),
+ CompositeCacheAttributes.defaults().UseMemoryShrinker(),
+ CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
maxMemoryIdleTimeSeconds,
- CompositeCacheAttributes.defaults().memoryCacheName(),
- CompositeCacheAttributes.defaults().diskUsagePattern(),
- CompositeCacheAttributes.defaults().spoolChunkSize());
+ CompositeCacheAttributes.defaults().MemoryCacheName(),
+ CompositeCacheAttributes.defaults().DiskUsagePattern(),
+ CompositeCacheAttributes.defaults().SpoolChunkSize());
}
/**
@@ -120,18 +112,16 @@ public class TestCompositeCacheAttributes
*
* @param diskUsagePattern the new diskUsagePattern value
*/
- public static CompositeCacheAttributes withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern diskUsagePattern)
+ public static CompositeCacheAttributes withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePatternEnum diskUsagePattern)
{
return new CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
- CompositeCacheAttributes.defaults().maxObjects(),
- CompositeCacheAttributes.defaults().useLateral(),
- CompositeCacheAttributes.defaults().useDisk(),
- CompositeCacheAttributes.defaults().useMemoryShrinker(),
- CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
- CompositeCacheAttributes.defaults().maxSpoolPerRun(),
- CompositeCacheAttributes.defaults().maxMemoryIdleTimeSeconds(),
- CompositeCacheAttributes.defaults().memoryCacheName(),
+ CompositeCacheAttributes.defaults().MaxObjects(),
+ CompositeCacheAttributes.defaults().UseMemoryShrinker(),
+ CompositeCacheAttributes.defaults().ShrinkerIntervalSeconds(),
+ CompositeCacheAttributes.defaults().MaxSpoolPerRun(),
+ CompositeCacheAttributes.defaults().MaxMemoryIdleTimeSeconds(),
+ CompositeCacheAttributes.defaults().MemoryCacheName(),
diskUsagePattern,
- CompositeCacheAttributes.defaults().spoolChunkSize());
+ CompositeCacheAttributes.defaults().SpoolChunkSize());
}
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
index 92007acd..29947fbb 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
@@ -35,12 +35,12 @@ public class TestElementAttributes
public static ElementAttributes withEternalFalseAndMaxLife(long maxLife)
{
ElementAttributes element = new ElementAttributes(
- ElementAttributes.defaults().isSpool(),
- ElementAttributes.defaults().isLateral(),
- ElementAttributes.defaults().isRemote(),
+ ElementAttributes.defaults().IsSpool(),
+ ElementAttributes.defaults().IsLateral(),
+ ElementAttributes.defaults().IsRemote(),
false,
maxLife,
- ElementAttributes.defaults().maxIdleTime(),
+ ElementAttributes.defaults().MaxIdleTime(),
System.currentTimeMillis(),
new AtomicLong(),
ElementAttributes.defaults().timeFactorForMilliseconds(),
@@ -59,9 +59,9 @@ public class TestElementAttributes
public static ElementAttributes withEternalFalseAndMaxLifeAndMaxIdleTime(long maxLife, long maxIdleTime)
{
ElementAttributes element = new ElementAttributes(
- ElementAttributes.defaults().isSpool(),
- ElementAttributes.defaults().isLateral(),
- ElementAttributes.defaults().isRemote(),
+ ElementAttributes.defaults().IsSpool(),
+ ElementAttributes.defaults().IsLateral(),
+ ElementAttributes.defaults().IsRemote(),
false,
maxLife,
maxIdleTime,
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java
index 0a2e71a9..e24e4050 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfiguratorUnitTest.java
@@ -98,6 +98,6 @@ class CompositeCacheConfiguratorUnitTest
// VERIFY
final CompositeCache<String, String> cache = manager.getCache( regionName );
- assertEquals( cache.getCacheAttributes().spoolChunkSize(), chunkSize, "Wrong chunkSize" );
+ assertEquals( cache.getCacheAttributes().SpoolChunkSize(), chunkSize, "Wrong chunkSize" );
}
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java
index b787301d..7c634f57 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java
@@ -240,7 +240,7 @@ class CompositeCacheDiskUsageUnitTest
{
// SETUP
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
- .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.SWAP)
+ .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePatternEnum.SWAP)
.withCacheName(CACHE_NAME);
final IElementAttributes attr = new ElementAttributes();
@@ -270,7 +270,7 @@ class CompositeCacheDiskUsageUnitTest
{
// SETUP
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
- .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+ .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePatternEnum.UPDATE)
.withCacheName(CACHE_NAME);
final IElementAttributes attr = new ElementAttributes();
@@ -300,8 +300,8 @@ class CompositeCacheDiskUsageUnitTest
throws CacheException
{
final CacheAccess<String, String> swap = JCS.getInstance( "Swap" );
- assertEquals( ICompositeCacheAttributes.DiskUsagePattern.SWAP,
- swap.getCacheAttributes().diskUsagePattern() );
+ assertEquals( ICompositeCacheAttributes.DiskUsagePatternEnum.SWAP,
+ swap.getCacheAttributes().DiskUsagePattern() );
}
/**
@@ -318,7 +318,7 @@ class CompositeCacheDiskUsageUnitTest
{
// SETUP
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
- .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+ .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePatternEnum.UPDATE)
.withCacheName(CACHE_NAME);
final IElementAttributes attr = new ElementAttributes();
@@ -354,7 +354,7 @@ class CompositeCacheDiskUsageUnitTest
{
// SETUP
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
- .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+ .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePatternEnum.UPDATE)
.withCacheName(CACHE_NAME);
final IElementAttributes attr = new ElementAttributes();
@@ -389,7 +389,7 @@ class CompositeCacheDiskUsageUnitTest
{
// SETUP
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
- .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+ .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePatternEnum.UPDATE)
.withCacheName(CACHE_NAME);
final IElementAttributes attr = new ElementAttributes();
@@ -426,8 +426,8 @@ class CompositeCacheDiskUsageUnitTest
throws CacheException
{
final CacheAccess<String, String> swap = JCS.getInstance( "Update" );
- assertEquals( ICompositeCacheAttributes.DiskUsagePattern.UPDATE,
- swap.getCacheAttributes().diskUsagePattern() );
+ assertEquals( ICompositeCacheAttributes.DiskUsagePatternEnum.UPDATE,
+ swap.getCacheAttributes().DiskUsagePattern() );
}
/**
@@ -445,7 +445,7 @@ class CompositeCacheDiskUsageUnitTest
{
// SETUP
final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
- .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.SWAP)
+ .withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePatternEnum.SWAP)
.withCacheName(CACHE_NAME);
final IElementAttributes attr = new ElementAttributes();
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
index 8476d3f3..e70b5497 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
@@ -204,7 +204,7 @@ class SimpleEventHandlingUnitTest
}
// wait a bit for the items to expire
- Thread.sleep(attributes.maxIdleTime() * 1000 + 100);
+ Thread.sleep(attributes.MaxIdleTime() * 1000 + 100);
for ( int i = 0; i < 200; i++ )
{
@@ -242,7 +242,7 @@ class SimpleEventHandlingUnitTest
}
// wait a bit for the items to expire
- Thread.sleep(attributes.maxLife() * 1000 + 100);
+ Thread.sleep(attributes.MaxLife() * 1000 + 100);
for ( int i = 0; i < 200; i++ )
{
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
index 74b46a0d..90a98e98 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
@@ -61,7 +61,7 @@ class LHMLRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testClearThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -96,7 +96,7 @@ class LHMLRUMemoryCacheUnitTest
final LHMLRUMemoryCache<String, String> mru = new LHMLRUMemoryCache<>();
mru.initialize( cache );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max / 2;
for ( int i = 0; i < items; i++ )
@@ -122,7 +122,7 @@ class LHMLRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testGetStatsThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -149,7 +149,7 @@ class LHMLRUMemoryCacheUnitTest
throws CacheException
{
final CacheAccess<String, String> cache = JCS.getInstance( "testLoadFromCCF" );
- final String memoryCacheName = cache.getCacheAttributes().memoryCacheName();
+ final String memoryCacheName = cache.getCacheAttributes().MemoryCacheName();
assertTrue( memoryCacheName.indexOf( "LHMLRUMemoryCache" ) != -1, "Cache name should have LHMLRU in it." );
}
@@ -164,7 +164,7 @@ class LHMLRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -219,7 +219,7 @@ class LHMLRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHubTwice" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -260,7 +260,7 @@ class LHMLRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutRemoveThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -292,7 +292,7 @@ class LHMLRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testRemovePartialThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max / 2;
cache.put( "test", "data" );
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/mru/MRUMemoryCacheUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/mru/MRUMemoryCacheUnitTest.java
index 265011c5..c49ee88f 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/mru/MRUMemoryCacheUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/mru/MRUMemoryCacheUnitTest.java
@@ -61,7 +61,7 @@ class MRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -96,7 +96,7 @@ class MRUMemoryCacheUnitTest
final MRUMemoryCache<String, String> mru = new MRUMemoryCache<>();
mru.initialize( cache );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max / 2;
for ( int i = 0; i < items; i++ )
@@ -122,7 +122,7 @@ class MRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testGetStatsThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -147,7 +147,7 @@ class MRUMemoryCacheUnitTest
throws CacheException
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGet" );
- final String memoryCacheName = cache.getCacheAttributes().memoryCacheName();
+ final String memoryCacheName = cache.getCacheAttributes().MemoryCacheName();
assertTrue( memoryCacheName.indexOf( "MRUMemoryCache" ) != -1, "Cache name should have MRU in it." );
}
@@ -162,7 +162,7 @@ class MRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -217,7 +217,7 @@ class MRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -258,7 +258,7 @@ class MRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -290,7 +290,7 @@ class MRUMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testGetStatsThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max / 2;
cache.put( "test", "data" );
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
index cf10cbb6..946bdd04 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
@@ -54,7 +54,7 @@ class ShrinkerThreadUnitTest
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
.withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().memoryCacheName(), 10, 10)
+ CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -88,7 +88,7 @@ class ShrinkerThreadUnitTest
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
.withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().memoryCacheName(), 10, 10)
+ CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -122,7 +122,7 @@ class ShrinkerThreadUnitTest
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
.withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().memoryCacheName(), 10, 10)
+ CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
@@ -156,7 +156,7 @@ class ShrinkerThreadUnitTest
// SETUP
final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
.withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
- CompositeCacheAttributes.defaults().memoryCacheName(), 10, 10)
+ CompositeCacheAttributes.defaults().MemoryCacheName(), 10, 10)
.withCacheName("testRegion");
final CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java
index f9bfced1..20578d7f 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java
@@ -72,7 +72,7 @@ class SoftReferenceMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -107,7 +107,7 @@ class SoftReferenceMemoryCacheUnitTest
final SoftReferenceMemoryCache<String, String> srmc = new SoftReferenceMemoryCache<>();
srmc.initialize( cache );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max / 2;
for ( int i = 0; i < items; i++ )
@@ -133,7 +133,7 @@ class SoftReferenceMemoryCacheUnitTest
throws CacheException
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGet" );
- final String memoryCacheName = cache.getCacheAttributes().memoryCacheName();
+ final String memoryCacheName = cache.getCacheAttributes().MemoryCacheName();
assertTrue( memoryCacheName.indexOf( "SoftReferenceMemoryCache" ) != -1,
"Cache name should have SoftReference in it." );
}
@@ -149,7 +149,7 @@ class SoftReferenceMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -193,7 +193,7 @@ class SoftReferenceMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testPutGetThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max * 2;
for ( int i = 0; i < items; i++ )
@@ -225,7 +225,7 @@ class SoftReferenceMemoryCacheUnitTest
{
final CacheAccess<String, String> cache = JCS.getInstance( "testGetStatsThroughHub" );
- final int max = cache.getCacheAttributes().maxObjects();
+ final int max = cache.getCacheAttributes().MaxObjects();
final int items = max / 2;
cache.put( "test", "data" );
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
index 641b7920..9706a59a 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
@@ -75,8 +75,8 @@ class SerializationConversionUtilUnitTest
// VERIFY
assertNotNull( after, "Should have a deserialized object." );
assertEquals( before.value(), after.value(), "Values should be the same." );
- assertEquals( before.elementAttributes().maxLife(), after
- .elementAttributes().maxLife(), "Attributes should be the same." );
+ assertEquals( before.elementAttributes().MaxLife(), after
+ .elementAttributes().MaxLife(), "Attributes should be the same." );
assertEquals( before.key(), after.key(), "Keys should be the same." );
assertEquals( before.cacheName(), after.cacheName(), "Cache name should be the same." );
}
@@ -188,8 +188,8 @@ class SerializationConversionUtilUnitTest
// VERIFY
assertNotNull( after, "Should have a deserialized object." );
assertEquals( before.value(), after.value(), "Values should be the same." );
- assertEquals( before.elementAttributes().maxLife(), after
- .elementAttributes().maxLife(), "Attributes should be the same." );
+ assertEquals( before.elementAttributes().MaxLife(), after
+ .elementAttributes().MaxLife(), "Attributes should be the same." );
assertEquals( before.key(), after.key(), "Keys should be the same." );
assertEquals( before.cacheName(), after.cacheName(), "Cache name should be the same." );
}
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java
index 0ff59e10..4fbc36da 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCache.java
@@ -323,7 +323,7 @@ public class JCSCache<K, V> implements Cache<K, V>
{
forceExpires(key);
}
- else if (expiryForAccess != null && (!elt.elementAttributes().isEternal() || !expiryForAccess.isEternal()))
+ else if (expiryForAccess != null && (!elt.elementAttributes().IsEternal() || !expiryForAccess.isEternal()))
{
try
{
@@ -701,8 +701,8 @@ public class JCSCache<K, V> implements Cache<K, V>
if (created && duration != null) { // set maxLife
final long timeFactorForMilliseconds = 1;
final boolean eternal = duration.isEternal();
- long maxIdleTime = attributes.maxIdleTime();
- long maxLife = attributes.maxLife();
+ long maxIdleTime = attributes.MaxIdleTime();
+ long maxLife = attributes.MaxLife();
if (!eternal)
{
if (duration == expiryPolicy.getExpiryForAccess())
@@ -715,9 +715,9 @@ public class JCSCache<K, V> implements Cache<K, V>
}
}
attributes = new ElementAttributes(
- attributes.isSpool(),
- attributes.isLateral(),
- attributes.isRemote(),
+ attributes.IsSpool(),
+ attributes.IsLateral(),
+ attributes.IsRemote(),
eternal,
maxLife,
maxIdleTime,
@@ -917,7 +917,7 @@ public class JCSCache<K, V> implements Cache<K, V>
if (value != null)
{
final Duration expiryForAccess = expiryPolicy.getExpiryForAccess();
- if (expiryForAccess != null && (!elt.elementAttributes().isEternal() || !expiryForAccess.isEternal()))
+ if (expiryForAccess != null && (!elt.elementAttributes().IsEternal() || !expiryForAccess.isEternal()))
{
try
{
@@ -973,12 +973,12 @@ public class JCSCache<K, V> implements Cache<K, V>
IElementAttributes newAttributes = (duration != null) ?
// MaxLife = -1 to use IdleTime excepted if jcache.ccf asked for something else
new ElementAttributes(
- attrs.isSpool(),
- attrs.isLateral(),
- attrs.isRemote(),
+ attrs.IsSpool(),
+ attrs.IsLateral(),
+ attrs.IsRemote(),
duration.isEternal(),
- attrs.maxLife(),
- attrs.maxIdleTime(),
+ attrs.MaxLife(),
+ attrs.MaxIdleTime(),
1)
: attrs;
diff --git a/src/site/xdoc/ElementAttributes.xml b/src/site/xdoc/ElementAttributes.xml
index 5b9164c9..fbfb6162 100644
--- a/src/site/xdoc/ElementAttributes.xml
+++ b/src/site/xdoc/ElementAttributes.xml
@@ -72,63 +72,99 @@ jcs.default.elementattributes.MaxIdleTime=1800
settings). In addition, by default all regions will
take these element configuration settings.
</p>
- <p>
- These settings specify that elements are not
- eternal, i.e. they can expire. By default elements
- are considered eternal.
- </p>
- <p>
- You can define the maximum life of an item by
- setting the
- <code>MaxLife</code>
- parameter. If an item has been in the cache for
- longer than the set number of seconds it will not be
- retrieved on a get request. If you use the memory
- shrinker the item will be actively removed from
- memory. Currently there is no background disk
- shrinker, but the disk cache does allow for a
- maximum number of keys (see
- <a href="IndexedDiskAuxCache.html">
- Indexed Disk Cache
- </a>
- for more information on the disk cache settings).
- </p>
- <p>
- You can define the maximum time an item can live
- without being accessed by setting the
- <code>MaxIdleTime</code>
- parameter. This is different than the
- <code>MaxMemoryIdleTimeSeconds</code>
- parameter, which just specifies how long an object
- can be in memory before it is subjected to removal
- or being spooled to a disk cache if it is available.
- Note: the
- <code>MaxIdleTime</code>
- parameter may not function properly for items
- retrieved from disk, if you have a memory size of 0.
- </p>
+ </subsection>
+
+ <subsection name="Properties Reference">
+ <table>
+ <tr>
+ <th>Property</th>
+ <th>Description</th>
+ <th>Required</th>
+ <th>Default Value</th>
+ </tr>
+ <tr>
+ <td>IsEternal</td>
+ <td>
+ This setting specifies that elements are not
+ eternal, i.e. they can expire. By default elements
+ are considered eternal.
+ </td>
+ <td>N</td>
+ <td>true</td>
+ </tr>
+ <tr>
+ <td>MaxLife</td>
+ <td>
+ You can define the maximum life of an item by setting the
+ <code>MaxLife</code>
+ parameter. If an item has been in the cache for
+ longer than the set duration it will not be
+ retrieved on a get request. If you use the memory
+ shrinker the item will be actively removed from
+ memory. Currently there is no background disk
+ shrinker, but the disk cache does allow for a
+ maximum number of keys (see
+ <a href="IndexedDiskAuxCache.html">
+ Indexed Disk Cache
+ </a>
+ for more information on the disk cache settings).
+ </td>
+ <td>N</td>
+ <td>-1 (unlimited)</td>
+ </tr>
+ <tr>
+ <td>MaxIdleTime</td>
+ <td>
+ You can define the maximum time an item can live
+ without being accessed by setting the
+ <code>MaxIdleTime</code>
+ parameter. This is different than the
+ <code>MaxMemoryIdleTimeSeconds</code>
+ parameter, which just specifies how long an object
+ can be in memory before it is subjected to removal
+ or being spooled to a disk cache if it is available.
+ Note: the
+ <code>MaxIdleTime</code>
+ parameter may not function properly for items
+ retrieved from disk, if you have a memory size of 0.
+ </td>
+ <td>N</td>
+ <td>-1 (unlimited)</td>
+ </tr>
+ <tr>
+ <td>IsSpool</td>
+ <td>
+ <code>IsSpool</code>
+ determines whether or not the element can go to disk, if
+ a disk cache is configured for the region.
+ </td>
+ <td>N</td>
+ <td>true</td>
+ </tr>
+ <tr>
+ <td>IsRemote</td>
+ <td>
+ <code>IsRemote</code>
+ determines whether or not the element can be sent to a
+ remote server, if one is configured for the region.
+ </td>
+ <td>N</td>
+ <td>true</td>
+ </tr>
+ <tr>
+ <td>IsLateral</td>
+ <td>
+ <code>IsLateral</code>
+ determines whether or not the element can be laterally
+ distributed, if a lateral auxiliary is configured for
+ the region.
+ </td>
+ <td>N</td>
+ <td>true</td>
+ </tr>
+ </table>
</subsection>
- <p>
- <code>IsSpool</code>
- determines whether or not the element can go to disk, if
- a disk cache is configured for the region.
- The default is <code>true</code>.
- </p>
- <p>
- <code>IsRemote</code>
- determines whether or not the element can be sent to a
- remote server, if one is configured for the region.
- The default is <code>true</code>.
- </p>
- <p>
- <code>IsLateral</code>
- determines whether or not the element can be laterally
- distributed, if a lateral auxiliary is configured for
- the region.
- The default is <code>true</code>.
- </p>
-
<subsection name="Programmatic Configuration">
<p>
Every element put into the cache has its own set of
diff --git a/src/site/xdoc/RegionProperties.xml b/src/site/xdoc/RegionProperties.xml
index 1f5a3813..9e479841 100644
--- a/src/site/xdoc/RegionProperties.xml
+++ b/src/site/xdoc/RegionProperties.xml
@@ -142,6 +142,16 @@
<td>N</td>
<td>30</td>
</tr>
+ <tr>
+ <td>MaxSpoolPerRun</td>
+ <td>
+ If UseMemoryShrinker is true the memory cache should
+ auto-expire elements to reclaim space. This gets the
+ maximum number of items to spool per run.
+ </td>
+ <td>N</td>
+ <td>-1 (unlimited)</td>
+ </tr>
<tr>
<td>DiskUsagePattern</td>
<td>
@@ -169,6 +179,15 @@
<td>N</td>
<td>SWAP</td>
</tr>
+ <tr>
+ <td>SpoolChunkSize</td>
+ <td>
+ Number of items to send to disk at time when
+ memory is full.
+ </td>
+ <td>N</td>
+ <td>2</td>
+ </tr>
</table>
</subsection>
(commons-jcs) 11/11: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-jcs.git
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit c646b1d365136302f49c57e38184ae8b7d452e7b
Merge: 69189732 fa13fb41
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Thu Mar 19 10:13:23 2026 +0100
Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-jcs.git
.github/workflows/scorecards-analysis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(commons-jcs) 02/11: Support Duration as a data type
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 578e11f3fbd20f0c464cfa7bb4eab8ab04de2087
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Tue Mar 17 18:06:20 2026 +0100
Support Duration as a data type
---
.../jcs4/utils/config/ConfigurationBuilder.java | 37 +++++++++++-----------
.../commons/jcs4/utils/config/PropertySetter.java | 30 +++++++++++-------
.../jcs4/utils/config/PropertySetterUnitTest.java | 5 ++-
3 files changed, 41 insertions(+), 31 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/ConfigurationBuilder.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/ConfigurationBuilder.java
index 0b7eb7dc..ce35ea58 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/ConfigurationBuilder.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/ConfigurationBuilder.java
@@ -22,11 +22,11 @@ package org.apache.commons.jcs4.utils.config;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.RecordComponent;
+import java.time.Duration;
+import java.time.format.DateTimeParseException;
import java.util.HashMap;
-import java.util.Locale;
import java.util.Map;
import java.util.Properties;
-import java.util.regex.Pattern;
import org.apache.commons.jcs4.log.Log;
@@ -111,11 +111,7 @@ public class ConfigurationBuilder<T>
for (RecordComponent component : components)
{
- // Capitalize first letter of component name
- String name = Pattern.compile("^.").matcher(component.getName()).replaceFirst(
- m -> m.group().toUpperCase(Locale.ENGLISH));
-
- String fullKey = String.join(".", prefix, name);
+ String fullKey = String.join(".", prefix, component.getName());
String value = OptionConverter.findAndSubst(fullKey, props);
if (value != null)
@@ -188,24 +184,17 @@ public class ConfigurationBuilder<T>
{
return v;
}
- if ( Integer.TYPE.isAssignableFrom( type ) )
+ else if ( Integer.TYPE.isAssignableFrom( type ) )
{
return Integer.valueOf( v );
}
- if ( Long.TYPE.isAssignableFrom( type ) )
+ else if ( Long.TYPE.isAssignableFrom( type ) )
{
return Long.valueOf( v );
}
- if ( Boolean.TYPE.isAssignableFrom( type ) )
+ else if ( Boolean.TYPE.isAssignableFrom( type ) )
{
- if (Boolean.parseBoolean(v))
- {
- return Boolean.TRUE;
- }
- else
- {
- return Boolean.FALSE;
- }
+ return Boolean.valueOf(v);
}
else if( type.isEnum() )
{
@@ -217,6 +206,18 @@ public class ConfigurationBuilder<T>
{
return new File( v );
}
+ else if ( Duration.class.isAssignableFrom( type ) )
+ {
+ try
+ {
+ return Duration.parse(v);
+ }
+ catch (DateTimeParseException e)
+ {
+ log.warn("Parsing Duration failed for {0}, assuming milliseconds", v);
+ return Duration.ofMillis(Long.parseLong(v));
+ }
+ }
log.warn("Unknown type for conversion: {0} and value {1}", type, value);
return null;
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java
index bbc7687c..fbbff84b 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/config/PropertySetter.java
@@ -25,6 +25,8 @@ import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.File;
import java.lang.reflect.Method;
+import java.time.Duration;
+import java.time.format.DateTimeParseException;
import java.util.Properties;
import org.apache.commons.jcs4.log.Log;
@@ -102,24 +104,17 @@ public class PropertySetter
{
return val;
}
- if ( Integer.TYPE.isAssignableFrom( type ) )
+ else if ( Integer.TYPE.isAssignableFrom( type ) )
{
return Integer.valueOf( v );
}
- if ( Long.TYPE.isAssignableFrom( type ) )
+ else if ( Long.TYPE.isAssignableFrom( type ) )
{
return Long.valueOf( v );
}
- if ( Boolean.TYPE.isAssignableFrom( type ) )
+ else if ( Boolean.TYPE.isAssignableFrom( type ) )
{
- if ( "true".equalsIgnoreCase( v ) )
- {
- return Boolean.TRUE;
- }
- if ( "false".equalsIgnoreCase( v ) )
- {
- return Boolean.FALSE;
- }
+ return Boolean.valueOf(v);
}
else if( type.isEnum() )
{
@@ -131,6 +126,18 @@ public class PropertySetter
{
return new File( v );
}
+ else if ( Duration.class.isAssignableFrom( type ) )
+ {
+ try
+ {
+ return Duration.parse(v);
+ }
+ catch (DateTimeParseException e)
+ {
+ log.warn("Parsing Duration failed for {0}, assuming milliseconds", v);
+ return Duration.ofMillis(Long.parseLong(v));
+ }
+ }
return null;
}
@@ -201,7 +208,6 @@ public class PropertySetter
setProperty( key.substring( len ), value );
}
}
-
}
/**
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/config/PropertySetterUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/config/PropertySetterUnitTest.java
index 9218619b..6c5ed732 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/config/PropertySetterUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/config/PropertySetterUnitTest.java
@@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.io.File;
+import java.time.Duration;
import org.junit.jupiter.api.Test;
@@ -54,6 +55,8 @@ class PropertySetterUnitTest
final Object f = ps.convertArg("test.conf", File.class);
assertInstanceOf( File.class, f, "Should be a file" );
- }
+ final Object d = ps.convertArg("PT5s", Duration.class);
+ assertInstanceOf( Duration.class, d, "Should be a duration" );
+ }
}
(commons-jcs) 07/11: Use java.time.Instant instead of Unix time
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit b5cf590973fedb97dca97abb63f3597cb5b89840
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Wed Mar 18 18:33:34 2026 +0100
Use java.time.Instant instead of Unix time
---
.../apache/commons/jcs4/admin/JCSAdminBean.java | 13 ++---
.../jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java | 4 +-
.../commons/jcs4/engine/ElementAttributes.java | 55 ++++++++++++++--------
.../jcs4/engine/behavior/IElementAttributes.java | 16 +++++--
.../jcs4/engine/control/CompositeCache.java | 17 +++----
.../engine/memory/shrinking/ShrinkerThread.java | 5 +-
.../jcs4/JCSCacheElementRetrievalUnitTest.java | 9 ++--
.../indexed/AbstractIndexDiskCacheUnitTest.java | 9 ++--
.../disk/indexed/IndexDiskCacheSizeUnitTest.java | 16 ++-----
.../IndexedDiskCacheConcurrentUnitTest.java | 1 -
.../commons/jcs4/engine/TestElementAttributes.java | 17 ++++---
.../control/event/SimpleEventHandlingUnitTest.java | 10 ++--
.../memory/shrinking/ShrinkerThreadUnitTest.java | 23 ++++-----
.../commons/jcs4/jcache/JCSCachingManager.java | 3 --
14 files changed, 110 insertions(+), 88 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java
index e32a5a60..2d16b720 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/admin/JCSAdminBean.java
@@ -22,8 +22,8 @@ package org.apache.commons.jcs4.admin;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import java.text.DateFormat;
-import java.util.Date;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -132,10 +132,7 @@ public class JCSAdminBean implements JCSJMXBean
.collect(Collectors.toMap(Object::toString, k -> k)));
final LinkedList<CacheElementInfo> records = new LinkedList<>();
-
- final DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT );
-
- final long now = System.currentTimeMillis();
+ final DateTimeFormatter format = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.systemDefault());
for (final Map.Entry<String, ?> key : keys.entrySet())
{
@@ -145,9 +142,9 @@ public class JCSAdminBean implements JCSJMXBean
final CacheElementInfo elementInfo = new CacheElementInfo(
key.getKey(),
attributes.IsEternal(),
- format.format(new Date(attributes.createTime())),
+ format.format(attributes.createTime()),
attributes.MaxLife(),
- (now - attributes.createTime() - attributes.MaxLife() * 1000 ) / -1000);
+ attributes.getTimeToLive().toSeconds());
records.add( elementInfo );
}
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
index 731b6aa5..1d3a07af 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
@@ -430,7 +430,7 @@ public class JDBCDiskCache<K, V>
psInsert.setLong( 4, ce.elementAttributes().MaxLife() );
psInsert.setString( 5, ce.elementAttributes().IsEternal() ? "T" : "F" );
- final Timestamp createTime = new Timestamp( ce.elementAttributes().createTime() );
+ final Timestamp createTime = Timestamp.from(ce.elementAttributes().createTime());
psInsert.setTimestamp( 6, createTime );
final long now = System.currentTimeMillis() / 1000;
@@ -477,7 +477,7 @@ public class JDBCDiskCache<K, V>
{
psUpdate.setBytes( 1, element );
- final Timestamp createTime = new Timestamp( ce.elementAttributes().createTime() );
+ final Timestamp createTime = Timestamp.from(ce.elementAttributes().createTime());
psUpdate.setTimestamp( 2, createTime );
final long now = System.currentTimeMillis() / 1000;
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
index d593dc3e..ae4f8b82 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
@@ -19,8 +19,10 @@ package org.apache.commons.jcs4.engine;
* under the License.
*/
+import java.io.Serializable;
+import java.time.Duration;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.jcs4.engine.behavior.IElementAttributes;
import org.apache.commons.jcs4.engine.control.event.behavior.IElementEventHandler;
@@ -63,10 +65,10 @@ public record ElementAttributes(
long MaxIdleTime,
/** The creation time. This is used to enforce the max life. */
- long createTime,
+ Instant createTime,
/** The last access time. This is used to enforce the max idle time. */
- AtomicLong mutableLastAccessTime,
+ LastAccessHolder mutableLastAccessTime,
/** The time factor to convert durations to milliseconds */
long timeFactorForMilliseconds,
@@ -84,6 +86,20 @@ public record ElementAttributes(
/** Don't change. */
private static final long serialVersionUID = 7814990748035017441L;
+ public static final class LastAccessHolder implements Serializable
+ {
+ private static final long serialVersionUID = 3995308126685776408L;
+ public Instant lastAccessTime;
+
+ /**
+ * @param lastAccessTime
+ */
+ public LastAccessHolder(Instant lastAccessTime)
+ {
+ this.lastAccessTime = lastAccessTime;
+ }
+ }
+
/** Default */
private static final boolean DEFAULT_IS_SPOOL = true;
/** Default */
@@ -107,8 +123,8 @@ public record ElementAttributes(
DEFAULT_IS_ETERNAL,
DEFAULT_MAX_LIFE,
DEFAULT_MAX_IDLE_TIME,
- 0,
- new AtomicLong(),
+ Instant.EPOCH,
+ new LastAccessHolder(Instant.EPOCH),
DEFAULT_TIME_FACTOR,
new ArrayList<>());
@@ -126,7 +142,7 @@ public record ElementAttributes(
public ElementAttributes()
{
this(defaults());
- this.mutableLastAccessTime.set(createTime());
+ this.mutableLastAccessTime.lastAccessTime = createTime();
}
/**
@@ -140,8 +156,8 @@ public record ElementAttributes(
from.IsEternal(),
from.MaxLife(),
from.MaxIdleTime(),
- System.currentTimeMillis(),
- new AtomicLong(from.lastAccessTime()),
+ Instant.now(),
+ new LastAccessHolder(from.lastAccessTime()),
from.timeFactorForMilliseconds(),
new ArrayList<>(from.elementEventHandlers()));
}
@@ -160,10 +176,10 @@ public record ElementAttributes(
)
{
this(isSpool, isLateral, isRemote, isEternal, maxLife, maxIdleTime,
- System.currentTimeMillis(), new AtomicLong(), timeFactorForMilliseconds,
+ Instant.now(), new LastAccessHolder(Instant.EPOCH), timeFactorForMilliseconds,
new ArrayList<>());
- this.mutableLastAccessTime.set(createTime());
+ this.mutableLastAccessTime.lastAccessTime = createTime();
}
/**
@@ -187,9 +203,9 @@ public record ElementAttributes(
* @return The LastAccess value.
*/
@Override
- public long lastAccessTime()
+ public Instant lastAccessTime()
{
- return mutableLastAccessTime().get();
+ return mutableLastAccessTime().lastAccessTime;
}
/**
@@ -198,19 +214,20 @@ public record ElementAttributes(
@Override
public void setLastAccessTimeNow()
{
- this.mutableLastAccessTime.set(System.currentTimeMillis());
+ this.mutableLastAccessTime.lastAccessTime = Instant.now();
}
/**
* Gets the time left to live of the IElementAttributes object.
* <p>
* This is the (max life + create time) - current time.
- * @return The TimeToLiveSeconds value
+ * @return The TimeToLive value
*/
- private long getTimeToLiveSeconds()
+ @Override
+ public Duration getTimeToLive()
{
- final long now = System.currentTimeMillis();
- return ( createTime() + MaxLife() * timeFactorForMilliseconds() - now ) / 1000;
+ final Instant now = Instant.now();
+ return Duration.between(now, createTime().plusMillis(MaxLife() * timeFactorForMilliseconds()));
}
/**
@@ -227,11 +244,11 @@ public record ElementAttributes(
dump.append( ", isSpool = " ).append( IsSpool() );
dump.append( ", isRemote = " ).append( IsRemote() );
dump.append( ", isEternal = " ).append( IsEternal() );
- dump.append( ", MaxLifeSeconds = " ).append( MaxLife() );
+ dump.append( ", MaxLife = " ).append( MaxLife() );
dump.append( ", MaxIdleTime = " ).append( MaxIdleTime() );
dump.append( ", CreateTime = " ).append( createTime() );
dump.append( ", LastAccessTime = " ).append( lastAccessTime() );
- dump.append( ", getTimeToLiveSeconds() = " ).append(getTimeToLiveSeconds());
+ dump.append( ", getTimeToLive() = " ).append(getTimeToLive());
dump.append( " ]" );
return dump.toString();
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
index 317ea27d..43ffeee9 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
@@ -20,6 +20,8 @@ package org.apache.commons.jcs4.engine.behavior;
*/
import java.io.Serializable;
+import java.time.Duration;
+import java.time.Instant;
import java.util.ArrayList;
import org.apache.commons.jcs4.engine.control.event.behavior.IElementEventHandler;
@@ -50,13 +52,13 @@ public interface IElementAttributes extends Serializable
/**
* Gets the createTime attribute of the IAttributes object.
* <p>
- * This should be the current time in milliseconds returned by the sysutem call when the element
+ * This should be the current time returned by the system call when the element
* is put in the cache.
* <p>
* Putting an item in the cache overrides any existing items.
* @return The createTime value
*/
- long createTime();
+ Instant createTime();
/**
* Gets the idleTime attribute of the IAttributes object
@@ -99,7 +101,7 @@ public interface IElementAttributes extends Serializable
*
* @return The LastAccess value.
*/
- long lastAccessTime();
+ Instant lastAccessTime();
/**
* Sets the MaxLife attribute of the IAttributes object. How many seconds it can live after
@@ -121,4 +123,12 @@ public interface IElementAttributes extends Serializable
* Sets the LastAccessTime as now of the IElementAttributes object
*/
void setLastAccessTimeNow();
+
+ /**
+ * Gets the time left to live of the IElementAttributes object.
+ * <p>
+ * This is the (max life + create time) - current time.
+ * @return The TimeToLive value
+ */
+ public Duration getTimeToLive();
}
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
index 6a947864..2d419f33 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCache.java
@@ -20,6 +20,7 @@ package org.apache.commons.jcs4.engine.control;
*/
import java.io.IOException;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -973,7 +974,7 @@ public class CompositeCache<K, V>
*/
public boolean isExpired(final ICacheElement<K, V> element)
{
- return isExpired(element, System.currentTimeMillis(),
+ return isExpired(element, Instant.now(),
ElementEventType.EXCEEDED_MAXLIFE_ONREQUEST,
ElementEventType.EXCEEDED_IDLETIME_ONREQUEST);
}
@@ -987,7 +988,7 @@ public class CompositeCache<K, V>
* @param eventIdle the event to fire in case the idle time is exceeded
* @return true if the element is expired
*/
- public boolean isExpired(final ICacheElement<K, V> element, final long timestamp,
+ public boolean isExpired(final ICacheElement<K, V> element, final Instant timestamp,
final ElementEventType eventMaxlife, final ElementEventType eventIdle)
{
try
@@ -996,12 +997,12 @@ public class CompositeCache<K, V>
if (!attributes.IsEternal())
{
- // Remove if maxLifeSeconds exceeded
- final long maxLifeSeconds = attributes.MaxLife();
- final long createTime = attributes.createTime();
+ // Remove if maxLife exceeded
+ final long maxLife = attributes.MaxLife();
+ final Instant createTime = attributes.createTime();
final long timeFactorForMilliseconds = attributes.timeFactorForMilliseconds();
- if (maxLifeSeconds != -1 && timestamp - createTime > maxLifeSeconds * timeFactorForMilliseconds)
+ if (maxLife != -1 && timestamp.isAfter(createTime.plusMillis(maxLife * timeFactorForMilliseconds)))
{
log.debug("Exceeded maxLife: {0}", element::key);
@@ -1009,13 +1010,13 @@ public class CompositeCache<K, V>
return true;
}
final long idleTime = attributes.MaxIdleTime();
- final long lastAccessTime = attributes.lastAccessTime();
+ final Instant lastAccessTime = attributes.lastAccessTime();
// Remove if maxIdleTime exceeded
// If you have a 0 size memory cache, then the last access will
// not get updated.
// you will need to set the idle time to -1.
- if (idleTime != -1 && timestamp - lastAccessTime > idleTime * timeFactorForMilliseconds)
+ if (idleTime != -1 && timestamp.isAfter(lastAccessTime.plusMillis(idleTime * timeFactorForMilliseconds)))
{
log.debug("Exceeded maxIdle: {0}", element::key);
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
index e895c479..83a2ca85 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThread.java
@@ -125,7 +125,7 @@ public class ShrinkerThread<K, V>
// removed and remove it if so.
if ( !attributes.IsEternal() )
{
- remove = cache.isExpired( cacheElement, now.toEpochMilli(),
+ remove = cache.isExpired( cacheElement, now,
ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND,
ElementEventType.EXCEEDED_IDLETIME_BACKGROUND );
@@ -142,8 +142,7 @@ public class ShrinkerThread<K, V>
{
if (!spoolLimit || spoolCount < this.maxSpoolPerRun)
{
- final Instant idleExpiryTime = Instant
- .ofEpochMilli(attributes.lastAccessTime())
+ final Instant idleExpiryTime = attributes.lastAccessTime()
.plus(maxMemoryIdleTime);
if (idleExpiryTime.isBefore(now))
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSCacheElementRetrievalUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSCacheElementRetrievalUnitTest.java
index 9d418bc7..3dfeba61 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSCacheElementRetrievalUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSCacheElementRetrievalUnitTest.java
@@ -22,6 +22,9 @@ package org.apache.commons.jcs4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.time.Duration;
+import java.time.Instant;
+
import org.apache.commons.jcs4.access.CacheAccess;
import org.apache.commons.jcs4.engine.behavior.ICacheElement;
import org.junit.jupiter.api.Test;
@@ -42,12 +45,12 @@ class JCSCacheElementRetrievalUnitTest
jcs.put( "test_key", "test_data" );
- final long now = System.currentTimeMillis();
+ final Instant now = Instant.now();
final ICacheElement<String, String> elem = jcs.getCacheElement( "test_key" );
assertEquals( "testCache1", elem.cacheName(), "Name wasn't right" );
- final long diff = now - elem.elementAttributes().createTime();
- assertTrue( diff >= 0, "Create time should have been at or after the call" );
+ final Duration diff = Duration.between(elem.elementAttributes().createTime(), now);
+ assertTrue( diff.toMillis() >= 0, "Create time should have been at or after the call" );
}
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java
index 0905a4b7..9af4033c 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java
@@ -46,7 +46,8 @@ import org.junit.jupiter.api.Test;
/**
* Tests for common functionality.
*/
-public abstract class AbstractIndexDiskCacheUnitTest{
+public abstract class AbstractIndexDiskCacheUnitTest
+{
public abstract IndexedDiskCacheAttributes getCacheAttributes();
/**
@@ -567,7 +568,7 @@ public abstract class AbstractIndexDiskCacheUnitTest{
cattr.setCacheName("testRecyleBinSize");
cattr.setDiskPath("target/test-sandbox/UnitTest");
cattr.setOptimizeAtRemoveCount(numberToInsert);
- cattr.setMaxKeySize(numberToInsert * 2);
+ cattr.setMaxKeySize(numberToInsert * 3);
cattr.setMaxPurgatorySize(numberToInsert);
final IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<>(cattr);
@@ -613,7 +614,7 @@ public abstract class AbstractIndexDiskCacheUnitTest{
cattr.setCacheName("testRecyleBinUsage");
cattr.setDiskPath("target/test-sandbox/UnitTest");
cattr.setOptimizeAtRemoveCount(numberToInsert);
- cattr.setMaxKeySize(numberToInsert * 2);
+ cattr.setMaxKeySize(numberToInsert * 3);
cattr.setMaxPurgatorySize(numberToInsert);
final IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<>(cattr);
@@ -651,7 +652,7 @@ public abstract class AbstractIndexDiskCacheUnitTest{
// verify that we used the correct number of spots
assertEquals( numberToAdd, disk.getRecyleCount(),
- "The recycle bin should have the number removed." + disk.getStatistics() );
+ "The recycle bin should have the number removed: " + disk.getStatistics() );
}
/**
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java
index 3c992a0a..f67db585 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java
@@ -49,11 +49,12 @@ public class IndexDiskCacheSizeUnitTest extends AbstractIndexDiskCacheUnitTest
final IndexedDiskCacheAttributes cattr = getCacheAttributes();
cattr.setCacheName( "testRemoveItems" );
cattr.setOptimizeAtRemoveCount(7);
- // 1kb DiskTestObject takes 1420 bytes, so 5*1420 = 7100, so to keep 5 objects, we need max key size of 8
- cattr.setMaxKeySize(8);
+ // 1kb DiskTestObject takes 2065 bytes, so 5*2065 = 10325, so to keep 5 objects, we need max key size of 12
+ cattr.setMaxKeySize(12);
cattr.setMaxPurgatorySize( 0 );
cattr.setDiskPath( "target/test-sandbox/BreakIndexTest" );
final IndexedDiskCache<String, DiskTestObject> disk = new IndexedDiskCache<>( cattr );
+ disk.removeAll(); // Make sure that cache is empty
final String[] test = { "a", "bb", "ccc", "dddd", "eeeee", "ffffff", "ggggggg", "hhhhhhhhh", "iiiiiiiiii" };
final String[] expect = { null, "bb", "ccc", null, null, "ffffff", null, "hhhhhhhhh", "iiiiiiiiii" };
@@ -61,7 +62,7 @@ public class IndexDiskCacheSizeUnitTest extends AbstractIndexDiskCacheUnitTest
for ( int i = 0; i < 6; i++ )
{
- final ICacheElement<String, DiskTestObject> element = new CacheElement<>( "testRecycleBin", "key:" + test[i], value);
+ final ICacheElement<String, DiskTestObject> element = new CacheElement<>("testRecycleBin", "key:" + test[i], value);
disk.processUpdate( element );
}
@@ -85,15 +86,6 @@ public class IndexDiskCacheSizeUnitTest extends AbstractIndexDiskCacheUnitTest
for ( int i = 0; i < 9; i++ )
{
final ICacheElement<String, DiskTestObject> element = disk.get( "key:" + test[i]);
- if ( element != null )
- {
- //System.out.println( "element = " + element.getVal() );
- }
- else
- {
- //System.out.println( "null --key:" + test[i]);
- }
-
final String expectedValue = expect[i];
if ( expectedValue == null )
{
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java
index a64fcd89..e90b037e 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java
@@ -39,7 +39,6 @@ import org.junit.jupiter.api.Test;
*/
public class IndexedDiskCacheConcurrentUnitTest
{
-
private static final int items = 200;
@BeforeEach
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
index 29947fbb..37e5bf39 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
@@ -1,5 +1,7 @@
package org.apache.commons.jcs4.engine;
+import java.time.Instant;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -20,7 +22,8 @@ package org.apache.commons.jcs4.engine;
*/
import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.commons.jcs4.engine.ElementAttributes.LastAccessHolder;
/**
* Allow test access to parametrized ElementAttributes objects
@@ -41,12 +44,12 @@ public class TestElementAttributes
false,
maxLife,
ElementAttributes.defaults().MaxIdleTime(),
- System.currentTimeMillis(),
- new AtomicLong(),
+ Instant.now(),
+ new LastAccessHolder(Instant.EPOCH),
ElementAttributes.defaults().timeFactorForMilliseconds(),
new ArrayList<>());
- element.mutableLastAccessTime().set(element.createTime());
+ element.mutableLastAccessTime().lastAccessTime = element.createTime();
return element;
}
@@ -65,12 +68,12 @@ public class TestElementAttributes
false,
maxLife,
maxIdleTime,
- System.currentTimeMillis(),
- new AtomicLong(),
+ Instant.now(),
+ new LastAccessHolder(Instant.EPOCH),
ElementAttributes.defaults().timeFactorForMilliseconds(),
new ArrayList<>());
- element.mutableLastAccessTime().set(element.createTime());
+ element.mutableLastAccessTime().lastAccessTime = element.createTime();
return element;
}
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
index e70b5497..b3fe61e5 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/event/SimpleEventHandlingUnitTest.java
@@ -19,11 +19,13 @@ package org.apache.commons.jcs4.engine.control.event;
* under the License.
*/
-import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.time.Instant;
+
import org.apache.commons.jcs4.JCS;
import org.apache.commons.jcs4.access.CacheAccess;
import org.apache.commons.jcs4.engine.ElementAttributes;
@@ -166,14 +168,14 @@ class SimpleEventHandlingUnitTest
throws Exception
{
final ElementAttributes elem1 = new ElementAttributes();
- final long ctime1 = elem1.createTime();
+ final Instant ctime1 = elem1.createTime();
Thread.sleep(10);
final IElementAttributes elem2 = new ElementAttributes(elem1);
- final long ctime2 = elem2.createTime();
+ final Instant ctime2 = elem2.createTime();
- assertFalse( ctime1 == ctime2, "Creation times should be different" );
+ assertNotEquals(ctime1, ctime2, "Creation times should be different" );
}
/**
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
index 806c0277..3005ee46 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
@@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.time.Duration;
+import java.time.Instant;
import org.apache.commons.jcs4.engine.CacheElement;
import org.apache.commons.jcs4.engine.CompositeCacheAttributes;
@@ -67,9 +68,9 @@ class ShrinkerThreadUnitTest
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
TestElementAttributes.withEternalFalseAndMaxLife(1));
- long now = System.currentTimeMillis();
+ Instant now = Instant.now();
// add two seconds
- now += 2000;
+ now = now.plusSeconds(2);
// DO WORK
final boolean result = cache.isExpired( element, now,
@@ -102,9 +103,9 @@ class ShrinkerThreadUnitTest
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(100, 1));
- long now = System.currentTimeMillis();
+ Instant now = Instant.now();
// add two seconds
- now += 2000;
+ now = now.plusSeconds(2);
// DO WORK
final boolean result = cache.isExpired( element, now,
@@ -137,9 +138,9 @@ class ShrinkerThreadUnitTest
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
TestElementAttributes.withEternalFalseAndMaxLife(1));
- long now = System.currentTimeMillis();
+ Instant now = Instant.now();
// subtract two seconds
- now -= 2000;
+ now = now.minusSeconds(2);
// DO WORK
final boolean result = cache.isExpired( element, now,
@@ -172,9 +173,9 @@ class ShrinkerThreadUnitTest
final ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value,
TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(100, 1));
- long now = System.currentTimeMillis();
+ Instant now = Instant.now();
// subtract two seconds
- now -= 2000;
+ now = now.minusSeconds(2);
// DO WORK
final boolean result = cache.isExpired( element, now,
@@ -217,7 +218,7 @@ class ShrinkerThreadUnitTest
assertNotNull( returnedElement1, "We should have received an element" );
// set this to 2 seconds ago.
- elementAttr.mutableLastAccessTime().set(System.currentTimeMillis() - 2000);
+ elementAttr.mutableLastAccessTime().lastAccessTime = Instant.now().minusSeconds(2);
// DO WORK
final ShrinkerThread<String, String> shrinker = new ShrinkerThread<>( cache );
@@ -264,7 +265,7 @@ class ShrinkerThreadUnitTest
assertNotNull( returnedElement1, "We should have received an element" );
// set this to 2 seconds ago.
- elementAttr.mutableLastAccessTime().set(System.currentTimeMillis() - 2000);
+ elementAttr.mutableLastAccessTime().lastAccessTime = Instant.now().minusSeconds(2);
}
// DO WORK
@@ -315,7 +316,7 @@ class ShrinkerThreadUnitTest
assertNotNull( returnedElement1, "We should have received an element" );
// set this to 2 seconds ago.
- elementAttr.mutableLastAccessTime().set(System.currentTimeMillis() - 2000);
+ elementAttr.mutableLastAccessTime().lastAccessTime = Instant.now().minusSeconds(2);
}
// DO WORK
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
index b7f458ec..317ee426 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSCachingManager.java
@@ -78,13 +78,10 @@ public class JCSCachingManager implements CacheManager
private static final String DEFAULT_CONFIG =
"""
jcs.default=DC
- jcs.default.cacheattributes=org.apache.commons.jcs4.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=200001
- jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTime=PT1h
jcs.default.cacheattributes.ShrinkerInterval=PT1m
- jcs.default.elementattributes=org.apache.commons.jcs4.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.MaxIdleTime=1800
(commons-jcs) 04/11: Change type of JDBCDiskCacheAttributes.ShrinkerInterval to Duration
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 396284d1a6726665bc2cbd48ee24fb34ad142be8
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Tue Mar 17 18:31:53 2026 +0100
Change type of JDBCDiskCacheAttributes.ShrinkerInterval to Duration
---
.../auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java | 8 ++++----
.../src/test/test-conf/TestJDBCDiskCacheShrink.ccf | 2 +-
src/site/xdoc/JDBCDiskCacheProperties.xml | 10 +++++-----
src/site/xdoc/UpgradingFrom3x.xml | 20 +++++++++++---------
4 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java
index da388bb5..166fad77 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java
@@ -236,11 +236,11 @@ public class JDBCDiskCacheAttributes
}
/**
- * @param shrinkerIntervalSecondsArg The shrinkerIntervalSeconds to set.
+ * @param shrinkerInterval The shrinkerInterval to set.
*/
- public void setShrinkerIntervalSeconds( final int shrinkerIntervalSecondsArg )
+ public void setShrinkerInterval( final Duration shrinkerInterval )
{
- this.shrinkerInterval = Duration.ofSeconds(shrinkerIntervalSecondsArg);
+ this.shrinkerInterval = shrinkerInterval;
}
/**
@@ -303,7 +303,7 @@ public class JDBCDiskCacheAttributes
buf.append( "\n TestBeforeInsert [" + isTestBeforeInsert() + "]" );
buf.append( "\n MaxActive [" + getMaxTotal() + "]" );
buf.append( "\n AllowRemoveAll [" + isAllowRemoveAll() + "]" );
- buf.append( "\n ShrinkerIntervalSeconds [" + getShrinkerInterval() + "]" );
+ buf.append( "\n ShrinkerInterval [" + getShrinkerInterval() + "]" );
buf.append( "\n useDiskShrinker [" + isUseDiskShrinker() + "]" );
return buf.toString();
}
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
index 33eeffda..a45401bf 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheShrink.ccf
@@ -54,7 +54,7 @@ jcs.auxiliary.JDBC.attributes.maxTotal=14
jcs.auxiliary.JDBC.attributes.allowRemoveAll=true
jcs.auxiliary.JDBC.attributes.MaxPurgatorySize=9999
jcs.auxiliary.JDBC.attributes.UseDiskShrinker=true
-jcs.auxiliary.JDBC.attributes.ShrinkerIntervalSeconds=1
+jcs.auxiliary.JDBC.attributes.ShrinkerInterval=PT1S
jcs.auxiliary.JDBC.attributes.EventQueueType=POOLED
jcs.auxiliary.JDBC.attributes.EventQueuePoolName=disk_cache_event_queue
diff --git a/src/site/xdoc/JDBCDiskCacheProperties.xml b/src/site/xdoc/JDBCDiskCacheProperties.xml
index 40d8ed45..dc0fb242 100644
--- a/src/site/xdoc/JDBCDiskCacheProperties.xml
+++ b/src/site/xdoc/JDBCDiskCacheProperties.xml
@@ -156,9 +156,9 @@
<tr>
<td>ShrinkerInterval</td>
- <td>How often should the disk shrinker run (in seconds).</td>
+ <td>Interval between disk shrinker runs.</td>
<td>N</td>
- <td>300</td>
+ <td>PT5M</td>
</tr>
</table>
@@ -181,7 +181,7 @@ jcs.auxiliary.JDBC.attributes.maxActive=15
jcs.auxiliary.JDBC.attributes.allowRemoveAll=true
jcs.auxiliary.JDBC.attributes.MaxPurgatorySize=10000000
jcs.auxiliary.JDBC.attributes.UseDiskShrinker=true
-jcs.auxiliary.JDBC.attributes.ShrinkerInterval=300
+jcs.auxiliary.JDBC.attributes.ShrinkerInterval=PT5M
]]>
</source>
</subsection>
@@ -249,9 +249,9 @@ jcs.auxiliary.JDBC.attributes.maxActive=15
jcs.auxiliary.JDBC.attributes.allowRemoveAll=true
jcs.auxiliary.JDBC.attributes.MaxPurgatorySize=10000000
jcs.auxiliary.JDBC.attributes.UseDiskShrinker=true
-jcs.auxiliary.JDBC.attributes.ShrinkerInterval=300
+jcs.auxiliary.JDBC.attributes.ShrinkerInterval=PT5M
jcs.auxiliary.JDBC.attributes.EventQueueType=POOLED
-jcs.auxiliary.JDBC.attributes.EventQueuePoolName=disk_cache_event_queueue
+jcs.auxiliary.JDBC.attributes.EventQueuePoolName=disk_cache_event_queue
##############################################################
################## OPTIONAL THREAD POOL CONFIGURATION #########
diff --git a/src/site/xdoc/UpgradingFrom3x.xml b/src/site/xdoc/UpgradingFrom3x.xml
index bc7c85bb..0bdd6953 100644
--- a/src/site/xdoc/UpgradingFrom3x.xml
+++ b/src/site/xdoc/UpgradingFrom3x.xml
@@ -134,15 +134,20 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
<th>New Property Name</th>
</tr>
<tr>
- <td>Region configuration (cacheattributes)</td>
+ <td>Region configuration (CompositeCacheAttributes)</td>
<td>DiskUsagePatternName</td>
<td>DiskUsagePattern</td>
</tr>
<tr>
- <td>Element configuration (elementattributes)</td>
+ <td>Element configuration (ElementAttributes)</td>
<td>IdleTime</td>
<td>MaxIdleTime</td>
</tr>
+ <tr>
+ <td>JDBC configuration (JDBCDiskCacheAttributes)</td>
+ <td>ShrinkerIntervalSeconds</td>
+ <td>ShrinkerInterval</td>
+ </tr>
</table>
</p>
<p>
@@ -178,17 +183,14 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
<th>Default Value</th>
</tr>
<tr>
- <td>Thread Pool Configuration (thread_pool)</td>
+ <td>Thread Pool Configuration (thread_pool, PoolConfiguration)</td>
<td>keepAliveTime</td>
<td>PT5M</td>
</tr>
<tr>
- <td>Region configuration (cacheattributes)</td>
- <td>DiskUsagePatternName</td>
- </tr>
- <tr>
- <td>Element configuration (elementattributes)</td>
- <td>IdleTime</td>
+ <td>JDBC Disk Cache configuration (JDBCDiskCacheAttributes)</td>
+ <td>ShrinkerInterval</td>
+ <td>PT5M</td>
</tr>
</table>
</p>
(commons-jcs) 03/11: Change type of PoolConfiguration.keepAliveTime to Duration
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit f8c2f6290e49598b77fc5fb25d9addaa0fb85635
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Tue Mar 17 18:07:14 2026 +0100
Change type of PoolConfiguration.keepAliveTime to Duration
---
.../commons/jcs4/engine/CacheEventQueue.java | 3 +-
.../engine/control/event/ElementEventQueue.java | 5 +--
.../jcs4/utils/discovery/UDPDiscoveryReceiver.java | 3 +-
.../jcs4/utils/threadpool/PoolConfiguration.java | 20 ++++++------
.../jcs4/utils/threadpool/ThreadPoolManager.java | 4 +--
.../src/test/test-conf/TestBlockDiskCache.ccf | 6 ++--
.../src/test/test-conf/TestBlockDiskCacheCon.ccf | 8 ++---
.../src/test/test-conf/TestBlockDiskCacheHuge.ccf | 4 +--
.../src/test/test-conf/TestDiskCache.ccf | 6 ++--
.../src/test/test-conf/TestDiskCacheCon.ccf | 8 ++---
.../src/test/test-conf/TestDiskCacheHuge.ccf | 4 +--
.../src/test/test-conf/TestDiskCacheNoMemory.ccf | 6 ++--
.../test/test-conf/TestDiskCacheUsagePattern.ccf | 8 ++---
.../src/test/test-conf/TestElementSerializer.ccf | 2 +-
.../src/test/test-conf/TestHSQLDiskCache.ccf | 2 +-
.../test/test-conf/TestHSQLDiskCacheConcurrent.ccf | 2 +-
.../src/test/test-conf/TestJCSvHashtablePerf.ccf | 6 ++--
.../src/test/test-conf/TestJDBCDiskCache.ccf | 2 +-
.../test/test-conf/TestJDBCDiskCacheRemoval.ccf | 2 +-
.../test/test-conf/TestJDBCDiskCacheSharedPool.ccf | 2 +-
.../src/test/test-conf/TestMySQLDiskCache.ccf | 2 +-
.../src/test/test-conf/TestRemoval.ccf | 6 ++--
.../src/test/test-conf/TestTCPLateralCache.ccf | 6 ++--
.../test-conf/TestTCPLateralIssueRemoveCache.ccf | 6 ++--
commons-jcs4-core/src/test/test-conf/cache.ccf | 6 ++--
.../src/test/test-conf/thread_pool.properties | 12 +++----
src/site/xdoc/BlockDiskCache.xml | 4 +--
src/site/xdoc/IndexedDiskAuxCache.xml | 7 +---
src/site/xdoc/IndexedDiskCacheProperties.xml | 2 +-
src/site/xdoc/JDBCDiskCache.xml | 6 ++--
src/site/xdoc/JDBCDiskCacheProperties.xml | 2 +-
src/site/xdoc/MySQLDiskCacheProperties.xml | 2 +-
src/site/xdoc/UpgradingFrom3x.xml | 37 ++++++++++++++++++++--
33 files changed, 115 insertions(+), 86 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CacheEventQueue.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CacheEventQueue.java
index da738431..0dc68083 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CacheEventQueue.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CacheEventQueue.java
@@ -70,8 +70,7 @@ public class CacheEventQueue<K, V>
{
// create a default pool with one worker thread to mimic the SINGLE queue behavior
return ThreadPoolManager.getInstance().createPool(
- new PoolConfiguration(false, 0, 1, 1, getWaitToDie().toMillisPart(),
- WhenBlockedPolicy.RUN, 1),
+ new PoolConfiguration(false, 0, 1, 1, getWaitToDie(), WhenBlockedPolicy.RUN, 1),
"CacheEventQueue.QProcessor-" + getCacheName());
}
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/event/ElementEventQueue.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/event/ElementEventQueue.java
index 9399811b..0a0948a9 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/event/ElementEventQueue.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/event/ElementEventQueue.java
@@ -20,6 +20,7 @@ package org.apache.commons.jcs4.engine.control.event;
*/
import java.io.IOException;
+import java.time.Duration;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -28,8 +29,8 @@ import org.apache.commons.jcs4.engine.control.event.behavior.IElementEventHandle
import org.apache.commons.jcs4.engine.control.event.behavior.IElementEventQueue;
import org.apache.commons.jcs4.log.Log;
import org.apache.commons.jcs4.utils.threadpool.PoolConfiguration;
-import org.apache.commons.jcs4.utils.threadpool.ThreadPoolManager;
import org.apache.commons.jcs4.utils.threadpool.PoolConfiguration.WhenBlockedPolicy;
+import org.apache.commons.jcs4.utils.threadpool.ThreadPoolManager;
/**
* An event queue is used to propagate ordered cache events to one and only one target listener.
@@ -54,7 +55,7 @@ public class ElementEventQueue
public ElementEventQueue()
{
queueProcessor = ThreadPoolManager.getInstance().createPool(
- new PoolConfiguration(false, 0, 1, 1, 0, WhenBlockedPolicy.RUN, 1), THREAD_PREFIX);
+ new PoolConfiguration(false, 0, 1, 1, Duration.ZERO, WhenBlockedPolicy.RUN, 1), THREAD_PREFIX);
log.debug( "Constructed: {0}", this );
}
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryReceiver.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryReceiver.java
index 2ec7c033..038ae0eb 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryReceiver.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryReceiver.java
@@ -31,6 +31,7 @@ import java.nio.channels.DatagramChannel;
import java.nio.channels.MembershipKey;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
+import java.time.Duration;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -105,7 +106,7 @@ public class UDPDiscoveryReceiver
// create a small thread pool to handle a barrage
this.pooledExecutor = ThreadPoolManager.getInstance().createPool(
- new PoolConfiguration(false, 0, maxPoolSize, maxPoolSize, 0,
+ new PoolConfiguration(false, 0, maxPoolSize, maxPoolSize, Duration.ZERO,
WhenBlockedPolicy.DISCARDOLDEST, maxPoolSize),
"JCS-UDPDiscoveryReceiver-", Thread.MIN_PRIORITY);
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/PoolConfiguration.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/PoolConfiguration.java
index d7c4d5b3..f99017c2 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/PoolConfiguration.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/PoolConfiguration.java
@@ -1,5 +1,7 @@
package org.apache.commons.jcs4.utils.threadpool;
+import java.time.Duration;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -39,7 +41,7 @@ public record PoolConfiguration(
int minimumPoolSize,
/** How long idle threads above the minimum should be kept alive. */
- int keepAliveTime,
+ Duration keepAliveTime,
/** Should be ABORT, BLOCK, RUN, WAIT, DISCARDOLDEST, */
WhenBlockedPolicy whenBlockedPolicy,
@@ -78,7 +80,7 @@ public record PoolConfiguration(
private static final int DEFAULT_MINIMUM_POOL_SIZE = Runtime.getRuntime().availableProcessors();
/** Default keep alive */
- private static final int DEFAULT_KEEPALIVE_TIME = 1000 * 60 * 5;
+ private static final Duration DEFAULT_KEEPALIVE_TIME = Duration.ofMinutes(5);
/** Default when blocked */
private static final WhenBlockedPolicy DEFAULT_WHEN_BLOCKED_POLICY = WhenBlockedPolicy.RUN;
@@ -110,13 +112,13 @@ public record PoolConfiguration(
public String toString()
{
final StringBuilder buf = new StringBuilder();
- buf.append( "useBoundary = [" + useBoundary() + "] " );
- buf.append( "boundarySize = [" + boundarySize() + "] " );
- buf.append( "maximumPoolSize = [" + maximumPoolSize() + "] " );
- buf.append( "minimumPoolSize = [" + minimumPoolSize() + "] " );
- buf.append( "keepAliveTime = [" + keepAliveTime() + "] " );
- buf.append( "whenBlockedPolicy = [" + whenBlockedPolicy() + "] " );
- buf.append( "startUpSize = [" + startUpSize() + "]" );
+ buf.append("useBoundary = [").append(useBoundary()).append("] ");
+ buf.append("boundarySize = [").append(boundarySize()).append("] ");
+ buf.append("maximumPoolSize = [").append(maximumPoolSize()).append("] ");
+ buf.append("minimumPoolSize = [").append(minimumPoolSize()).append("] ");
+ buf.append("keepAliveTime = [").append(keepAliveTime()).append("] ");
+ buf.append("whenBlockedPolicy = [").append(whenBlockedPolicy()).append("] ");
+ buf.append("startUpSize = [").append(startUpSize()).append("]" );
return buf.toString();
}
}
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/ThreadPoolManager.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/ThreadPoolManager.java
index 4365ec57..cfb8dcc8 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/ThreadPoolManager.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/threadpool/ThreadPoolManager.java
@@ -144,7 +144,7 @@ public static void dispose()
{
final PoolConfiguration config = ConfigurationBuilder
.create(PoolConfiguration.class, defaultPoolConfiguration)
- .fromProperties(props, root + ".")
+ .fromProperties(props, root)
.build();
log.debug( "{0} PoolConfiguration = {1}", root, config );
@@ -240,7 +240,7 @@ public static void dispose()
final ThreadPoolExecutor pool = new ThreadPoolExecutor(
config.startUpSize(),
config.maximumPoolSize(),
- config.keepAliveTime(),
+ config.keepAliveTime().toMillis(),
TimeUnit.MILLISECONDS,
queue,
new DaemonThreadFactory(threadNamePrefix, threadPriority));
diff --git a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf
index 65c53779..1f5dacea 100644
--- a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCache.ccf
@@ -51,7 +51,7 @@ jcs.auxiliary.blockDiskCache2.attributes.DiskPath=target/test-sandbox/block-disk
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -61,7 +61,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -69,7 +69,7 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf
index 8ac3eb5b..d84c32a4 100644
--- a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheCon.ccf
@@ -49,7 +49,7 @@ jcs.auxiliary.blockDiskCache.attributes.EventQueuePoolName=disk_cache_event_queu
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -59,20 +59,20 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=1
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=1
# Disk Cache pool
thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.minimumPoolSize=2
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.startUpSize=10
# Remote cache client thread pool config
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf
index f2ce19e6..b052e3f8 100644
--- a/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestBlockDiskCacheHuge.ccf
@@ -44,7 +44,7 @@ jcs.auxiliary.blockDiskCache.attributes.EventQueueType=SINGLE
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -52,5 +52,5 @@ thread_pool.default.startUpSize=4
# Disk Cache pool
thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.minimumPoolSize=2
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf
index 1a360fa4..27e3989f 100644
--- a/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestDiskCache.ccf
@@ -51,7 +51,7 @@ jcs.auxiliary.indexedDiskCache2.attributes.DiskPath=target/test-sandbox/indexed-
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -61,7 +61,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -69,7 +69,7 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf
index 0d5e3d39..0dff31a5 100644
--- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheCon.ccf
@@ -50,7 +50,7 @@ jcs.auxiliary.indexedDiskCache.attributes.EventQueuePoolName=disk_cache_event_qu
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -60,20 +60,20 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=1
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=1
# Disk Cache pool
thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.minimumPoolSize=2
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.startUpSize=10
# Remote cache client thread pool config
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf
index 87574e16..d67276a6 100644
--- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheHuge.ccf
@@ -44,7 +44,7 @@ jcs.auxiliary.indexedDiskCache.attributes.EventQueueType=SINGLE
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -52,5 +52,5 @@ thread_pool.default.startUpSize=4
# Disk Cache pool
thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.minimumPoolSize=2
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf
index c65b8acf..45d5314e 100644
--- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheNoMemory.ccf
@@ -52,7 +52,7 @@ jcs.auxiliary.indexedDiskCache2.attributes.DiskPath=target/test-sandbox/indexed-
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -62,7 +62,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -70,6 +70,6 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf b/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf
index 66440eb2..b0e8e45d 100644
--- a/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestDiskCacheUsagePattern.ccf
@@ -45,7 +45,7 @@ jcs.auxiliary.indexedDiskCache.attributes.EventQueuePoolName=disk_cache_event_qu
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -55,20 +55,20 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=1
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=1
# Disk Cache pool
thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.minimumPoolSize=2
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.startUpSize=10
# Remote cache client thread pool config
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf b/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf
index 7e656e84..7fda0498 100644
--- a/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestElementSerializer.ccf
@@ -59,6 +59,6 @@ thread_pool.cache_event_queue.useBoundary=false
#thread_pool.cache_event_queue.boundarySize=2000
thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
index 39527dbf..bd1fbaf5 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCache.ccf
@@ -69,6 +69,6 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
index 08ec3078..d05e7e8c 100644
--- a/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestHSQLDiskCacheConcurrent.ccf
@@ -70,6 +70,6 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestJCSvHashtablePerf.ccf b/commons-jcs4-core/src/test/test-conf/TestJCSvHashtablePerf.ccf
index 88b11ef4..189d3545 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJCSvHashtablePerf.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJCSvHashtablePerf.ccf
@@ -32,7 +32,7 @@ jcs.region.testCache1.cacheattributes.MaxObjects=100000
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -42,7 +42,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -50,6 +50,6 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
index 9136aedd..fedbb061 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCache.ccf
@@ -49,6 +49,6 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
index fd9d260e..70a6d8f7 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheRemoval.ccf
@@ -50,6 +50,6 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
index 471aaef1..3bbf75e0 100644
--- a/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestJDBCDiskCacheSharedPool.ccf
@@ -69,6 +69,6 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
index 7a62b00c..f602bdc1 100644
--- a/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestMySQLDiskCache.ccf
@@ -54,6 +54,6 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5S
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoval.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoval.ccf
index c2cb64e9..3e1babf1 100644
--- a/commons-jcs4-core/src/test/test-conf/TestRemoval.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestRemoval.ccf
@@ -32,7 +32,7 @@ jcs.region.testCache1.cacheattributes.MaxObjects=1000
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -42,7 +42,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -50,6 +50,6 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf b/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf
index 130c8a66..553d6464 100644
--- a/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestTCPLateralCache.ccf
@@ -44,7 +44,7 @@ jcs.auxiliary.LTCP.attributes.OpenTimeOut=2002
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -54,7 +54,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -62,7 +62,7 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf b/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf
index 73fdd1a0..46af277d 100644
--- a/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/TestTCPLateralIssueRemoveCache.ccf
@@ -43,7 +43,7 @@ jcs.auxiliary.LTCP.attributes.IssueRemoveOnPut=true
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -53,7 +53,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -61,7 +61,7 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/cache.ccf b/commons-jcs4-core/src/test/test-conf/cache.ccf
index 383b4b20..380461c5 100644
--- a/commons-jcs4-core/src/test/test-conf/cache.ccf
+++ b/commons-jcs4-core/src/test/test-conf/cache.ccf
@@ -29,7 +29,7 @@ jcs.region.testCache1=
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -39,7 +39,7 @@ thread_pool.cache_event_queue.useBoundary=false
# thread_pool.cache_event_queue.boundarySize=2000
# thread_pool.cache_event_queue.maximumPoolSize=10
thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.keepAliveTime=PT3.5S
# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
thread_pool.cache_event_queue.startUpSize=5
@@ -47,6 +47,6 @@ thread_pool.cache_event_queue.startUpSize=5
thread_pool.remote_cache_client.boundarySize=75
thread_pool.remote_cache_client.maximumPoolSize=150
thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.keepAliveTime=PT5M50S
thread_pool.remote_cache_client.whenBlockedPolicy=RUN
thread_pool.remote_cache_client.startUpSize=4
diff --git a/commons-jcs4-core/src/test/test-conf/thread_pool.properties b/commons-jcs4-core/src/test/test-conf/thread_pool.properties
index 2fcfda37..18a995aa 100644
--- a/commons-jcs4-core/src/test/test-conf/thread_pool.properties
+++ b/commons-jcs4-core/src/test/test-conf/thread_pool.properties
@@ -23,7 +23,7 @@
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=6
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
# RUN ABORT WAIT BLOCK DISCARDOLDEST
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=6
@@ -32,7 +32,7 @@ thread_pool.default.startUpSize=6
thread_pool.test1.boundarySize=75
thread_pool.test1.maximumPoolSize=150
thread_pool.test1.minimumPoolSize=4
-thread_pool.test1.keepAliveTime=350001
+thread_pool.test1.keepAliveTime=PT5M51S
thread_pool.test1.whenBlockedPolicy=RUN
thread_pool.test1.startUpSize=4
@@ -40,7 +40,7 @@ thread_pool.test1.startUpSize=4
thread_pool.maxtest.boundarySize=72
thread_pool.maxtest.maximumPoolSize=142
thread_pool.maxtest.minimumPoolSize=5
-thread_pool.maxtest.keepAliveTime=350002
+thread_pool.maxtest.keepAliveTime=PT5M52S
thread_pool.maxtest.whenBlockedPolicy=RUN
thread_pool.maxtest.startUpSize=5
@@ -48,7 +48,7 @@ thread_pool.maxtest.startUpSize=5
thread_pool.aborttest.boundarySize=1
thread_pool.aborttest.maximumPoolSize=11
thread_pool.aborttest.minimumPoolSize=1
-thread_pool.aborttest.keepAliveTime=1
+thread_pool.aborttest.keepAliveTime=PT0.001s
thread_pool.aborttest.whenBlockedPolicy=ABORT
thread_pool.aborttest.startUpSize=1
@@ -57,7 +57,7 @@ thread_pool.withbound.useBoundary=true
thread_pool.withbound.boundarySize=1000
thread_pool.withbound.maximumPoolSize=11
thread_pool.withbound.minimumPoolSize=1
-thread_pool.withbound.keepAliveTime=1
+thread_pool.withbound.keepAliveTime=PT0.001s
thread_pool.withbound.whenBlockedPolicy=ABORT
thread_pool.withbound.startUpSize=1
@@ -67,6 +67,6 @@ thread_pool.nobound.useBoundary=false
thread_pool.nobound.boundarySize=1000
thread_pool.nobound.maximumPoolSize=11
thread_pool.nobound.minimumPoolSize=1
-thread_pool.nobound.keepAliveTime=1
+thread_pool.nobound.keepAliveTime=PT0.001s
thread_pool.nobound.whenBlockedPolicy=ABORT
thread_pool.nobound.startUpSize=1
diff --git a/src/site/xdoc/BlockDiskCache.xml b/src/site/xdoc/BlockDiskCache.xml
index 05951233..2a4c01ba 100644
--- a/src/site/xdoc/BlockDiskCache.xml
+++ b/src/site/xdoc/BlockDiskCache.xml
@@ -85,7 +85,7 @@ jcs.auxiliary.blockDiskCache.attributes.EventQueueType=SINGLE
thread_pool.default.boundarySize=2000
thread_pool.default.maximumPoolSize=150
thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
+thread_pool.default.keepAliveTime=PT5M50S
#RUN ABORT DISCARDOLDEST DISCARD
thread_pool.default.whenBlockedPolicy=RUN
thread_pool.default.startUpSize=4
@@ -93,7 +93,7 @@ thread_pool.default.startUpSize=4
# Disk Cache pool
thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.minimumPoolSize=2
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.startUpSize=10
]]>
</source>
diff --git a/src/site/xdoc/IndexedDiskAuxCache.xml b/src/site/xdoc/IndexedDiskAuxCache.xml
index a30f66de..94f12fb5 100644
--- a/src/site/xdoc/IndexedDiskAuxCache.xml
+++ b/src/site/xdoc/IndexedDiskAuxCache.xml
@@ -176,11 +176,6 @@ jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
data file will occur until shutdown. By default the
value is -1.
</p>
- <p>
- In version 1.2.7.9 of JCS, the optimization routine
- was significantly improved. It now occurs in place,
- without the aid of a temporary file.
- </p>
<source><![CDATA[
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=30000
]]></source>
@@ -275,7 +270,7 @@ jcs.auxiliary.DC2.attributes.EventQueuePoolName=disk_cache_event_queue
thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=1
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.startUpSize=1
]]></source>
</subsection>
diff --git a/src/site/xdoc/IndexedDiskCacheProperties.xml b/src/site/xdoc/IndexedDiskCacheProperties.xml
index e1fbb067..f4e91dd9 100644
--- a/src/site/xdoc/IndexedDiskCacheProperties.xml
+++ b/src/site/xdoc/IndexedDiskCacheProperties.xml
@@ -143,7 +143,7 @@ thread_pool.disk_cache_event_queue.boundarySize=50
thread_pool.disk_cache_event_queue.useBoundary=true
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=1
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.startUpSize=1
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
]]>
diff --git a/src/site/xdoc/JDBCDiskCache.xml b/src/site/xdoc/JDBCDiskCache.xml
index eb073da1..e9378389 100644
--- a/src/site/xdoc/JDBCDiskCache.xml
+++ b/src/site/xdoc/JDBCDiskCache.xml
@@ -74,7 +74,7 @@ thread_pool.disk_cache_event_queue.useBoundary=true
thread_pool.disk_cache_event_queue.boundarySize=1000
thread_pool.disk_cache_event_queue.maximumPoolSize=50
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
]]>
@@ -139,7 +139,7 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
]]>
@@ -201,7 +201,7 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
]]>
diff --git a/src/site/xdoc/JDBCDiskCacheProperties.xml b/src/site/xdoc/JDBCDiskCacheProperties.xml
index 5f9396dd..40d8ed45 100644
--- a/src/site/xdoc/JDBCDiskCacheProperties.xml
+++ b/src/site/xdoc/JDBCDiskCacheProperties.xml
@@ -260,7 +260,7 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
]]>
diff --git a/src/site/xdoc/MySQLDiskCacheProperties.xml b/src/site/xdoc/MySQLDiskCacheProperties.xml
index 37f12406..559d0fb6 100644
--- a/src/site/xdoc/MySQLDiskCacheProperties.xml
+++ b/src/site/xdoc/MySQLDiskCacheProperties.xml
@@ -181,7 +181,7 @@ thread_pool.disk_cache_event_queue.useBoundary=false
thread_pool.disk_cache_event_queue.boundarySize=500
thread_pool.disk_cache_event_queue.maximumPoolSize=15
thread_pool.disk_cache_event_queue.minimumPoolSize=10
-thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.keepAliveTime=PT3.5s
thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN
thread_pool.disk_cache_event_queue.startUpSize=10
]]>
diff --git a/src/site/xdoc/UpgradingFrom3x.xml b/src/site/xdoc/UpgradingFrom3x.xml
index 3c8f21ef..bc7c85bb 100644
--- a/src/site/xdoc/UpgradingFrom3x.xml
+++ b/src/site/xdoc/UpgradingFrom3x.xml
@@ -124,6 +124,7 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
<subsection name="Changed Configuration Behavior">
<p>
JCS 4.0.0 tries to pull some long-standing configuration inconsistencies straight.
+ Note that configuration keys are case-sensitive.
The following configuration keys have been renamed or removed:
<table>
@@ -157,9 +158,39 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
drawn from the associated factory. Again, see the examples in <code>src/test/test-conf</code>.
</p>
<p>
- The configuration holder objects CompositeCacheAttributes and ElementAttributes
- are now implemented as Java records and - as such - are largely immutable. This
- makes them much more robust against side-effects in concurrent environments.
+ The configuration holder objects CompositeCacheAttributes, ElementAttributes
+ and PoolConfiguration are now implemented as Java records and - as such - are largely
+ immutable. This makes them much more robust against side-effects in concurrent
+ environments.
+ </p>
+ <p>
+ Time related configuration items are now represented as <code>java.time.Duration</code>
+ internally. The corresponding configuration file properties are being parsed using
+ <code>Duration.parse()</code> and use the syntax documented
+ <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html#parse(java.lang.CharSequence)">here</a>.
+ If parsing fails, the value is assumed to be a millisecond duration. This change affects
+ the following configuration keys:
+
+ <table>
+ <tr>
+ <th>Attribute Type</th>
+ <th>Property Name</th>
+ <th>Default Value</th>
+ </tr>
+ <tr>
+ <td>Thread Pool Configuration (thread_pool)</td>
+ <td>keepAliveTime</td>
+ <td>PT5M</td>
+ </tr>
+ <tr>
+ <td>Region configuration (cacheattributes)</td>
+ <td>DiskUsagePatternName</td>
+ </tr>
+ <tr>
+ <td>Element configuration (elementattributes)</td>
+ <td>IdleTime</td>
+ </tr>
+ </table>
</p>
</subsection>
</section>
(commons-jcs) 09/11: Replace System.currentTimeMillis() with Instant.now()
Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 3f72abf3c8902b16a618e6c4b4b7b0cec15dec82
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Thu Mar 19 09:41:33 2026 +0100
Replace System.currentTimeMillis() with Instant.now()
---
.../jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java | 4 +-
.../commons/jcs4/engine/logging/CacheEvent.java | 10 ++--
.../jcs4/utils/discovery/DiscoveredService.java | 9 +--
.../jcs4/utils/discovery/UDPDiscoveryService.java | 5 +-
.../commons/jcs4/utils/timing/ElapsedTimer.java | 9 ++-
.../commons/jcs4/access/TestCacheAccess.java | 68 +++++++++-------------
.../discovery/UDPDiscoveryServiceUnitTest.java | 13 +++--
src/site/xdoc/UpgradingFrom3x.xml | 33 +++++++++--
8 files changed, 84 insertions(+), 67 deletions(-)
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
index 6088c4ca..8bab209c 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCache.java
@@ -186,7 +186,7 @@ public class JDBCDiskCache<K, V>
if (result.next())
{
getTableState().setState( TableStateType.DELETE_RUNNING );
- final long now = System.currentTimeMillis() / 1000;
+ final Instant now = Instant.now();
final String sql = String.format(SQL_DELETE_EXPIRED, getTableName());
@@ -194,7 +194,7 @@ public class JDBCDiskCache<K, V>
{
psDelete.setString( 1, "F" );
psDelete.setString( 2, getCacheName() );
- psDelete.setLong( 3, now );
+ psDelete.setLong( 3, now.getEpochSecond() );
setAlive(true);
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/logging/CacheEvent.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/logging/CacheEvent.java
index 63156df4..6f0d2355 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/logging/CacheEvent.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/logging/CacheEvent.java
@@ -19,7 +19,7 @@ package org.apache.commons.jcs4.engine.logging;
* under the License.
*/
-import java.util.Date;
+import java.time.Instant;
import org.apache.commons.jcs4.engine.logging.behavior.ICacheEvent;
import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger.CacheEventType;
@@ -27,7 +27,7 @@ import org.apache.commons.jcs4.engine.logging.behavior.ICacheEventLogger.CacheEv
/** It's returned from create and passed into log. */
public record CacheEvent<K>(
/** The time at which this object was created. */
- long createTime,
+ Instant createTime,
/** The auxiliary or other source of the event. */
String source,
@@ -53,7 +53,7 @@ public record CacheEvent<K>(
*/
public CacheEvent()
{
- this(System.currentTimeMillis(), null, null, null, null, null);
+ this(Instant.now(), null, null, null, null, null);
}
/**
@@ -68,7 +68,7 @@ public record CacheEvent<K>(
public CacheEvent(final String source, final String region, CacheEventType eventType,
String optionalDetails, K key)
{
- this(System.currentTimeMillis(), source, region, eventType, optionalDetails, key);
+ this(Instant.now(), source, region, eventType, optionalDetails, key);
}
/**
@@ -79,7 +79,7 @@ public record CacheEvent<K>(
{
final StringBuilder sb = new StringBuilder();
sb.append("CacheEvent: ").append(eventType)
- .append(" Created: ").append(new Date(createTime));
+ .append(" Created: ").append(createTime);
if (source != null)
{
sb.append(" Source: ").append(source);
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/DiscoveredService.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/DiscoveredService.java
index 52c10388..69d80e29 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/DiscoveredService.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/DiscoveredService.java
@@ -20,6 +20,7 @@ package org.apache.commons.jcs4.utils.discovery;
*/
import java.io.Serializable;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Objects;
@@ -43,7 +44,7 @@ public class DiscoveredService
private int servicePort;
/** Last time we heard from this service? */
- private long lastHearFromTime;
+ private Instant lastHearFromTime;
/**
* Default constructor
@@ -64,7 +65,7 @@ public class DiscoveredService
setServiceAddress( message.getHost() );
setCacheNames( message.getCacheNames() );
setServicePort( message.getPort() );
- setLastHearFromTime( System.currentTimeMillis() );
+ setLastHearFromTime(Instant.now());
}
/**
@@ -104,7 +105,7 @@ public class DiscoveredService
/**
* @return the lastHearFromTime.
*/
- public long getLastHearFromTime()
+ public Instant getLastHearFromTime()
{
return lastHearFromTime;
}
@@ -143,7 +144,7 @@ public class DiscoveredService
/**
* @param lastHearFromTime The lastHearFromTime to set.
*/
- public void setLastHearFromTime( final long lastHearFromTime )
+ public void setLastHearFromTime( final Instant lastHearFromTime )
{
this.lastHearFromTime = lastHearFromTime;
}
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryService.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryService.java
index 513c0f53..65ae7f0e 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryService.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryService.java
@@ -25,6 +25,7 @@ import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
@@ -254,12 +255,12 @@ public class UDPDiscoveryService
*/
protected void cleanup()
{
- final long now = System.currentTimeMillis();
+ final Instant now = Instant.now();
// the listeners need to be notified.
getDiscoveredServices().stream()
.filter(service -> {
- if (now - service.getLastHearFromTime() > getUdpDiscoveryAttributes().maxIdleTimeSec() * 1000)
+ if (now.isAfter(service.getLastHearFromTime().plusSeconds(getUdpDiscoveryAttributes().maxIdleTimeSec())))
{
log.info( "Removing service, since we haven't heard from it in "
+ "{0} seconds. service = {1}",
diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/timing/ElapsedTimer.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/timing/ElapsedTimer.java
index acf80fe8..5832c8eb 100644
--- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/timing/ElapsedTimer.java
+++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/timing/ElapsedTimer.java
@@ -19,6 +19,9 @@ package org.apache.commons.jcs4.utils.timing;
* under the License.
*/
+import java.time.Duration;
+import java.time.Instant;
+
/**
* This is a simple timer utility.
*/
@@ -30,7 +33,7 @@ public class ElapsedTimer
/**
* Sets the start time when created.
*/
- private long timeStamp = System.currentTimeMillis();
+ private Instant timeStamp = Instant.now();
/**
* Gets the time elapsed between the start time and now. The start time is reset to now.
@@ -40,8 +43,8 @@ public class ElapsedTimer
*/
public long getElapsedTime()
{
- final long now = System.currentTimeMillis();
- final long elapsed = now - timeStamp;
+ final Instant now = Instant.now();
+ final long elapsed = Duration.between(timeStamp, now).toMillis();
timeStamp = now;
return elapsed;
}
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/TestCacheAccess.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/TestCacheAccess.java
index 92d843ca..7660f195 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/TestCacheAccess.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/TestCacheAccess.java
@@ -33,6 +33,7 @@ import org.apache.commons.jcs4.engine.ElementAttributes;
import org.apache.commons.jcs4.engine.behavior.IElementAttributes;
import org.apache.commons.jcs4.engine.control.event.ElementEventHandlerMockImpl;
import org.apache.commons.jcs4.log.Log;
+import org.apache.commons.jcs4.utils.timing.ElapsedTimer;
/**
* Allows the user to run common cache commands from the command line for a test cache. This also
@@ -167,7 +168,7 @@ public class TestCacheAccess
*/
public void getMultiple( final int num, final boolean show )
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
for ( int n = 0; n < num; n++ )
{
try
@@ -183,8 +184,7 @@ public class TestCacheAccess
log.error( e );
}
}
- final long n_end = System.currentTimeMillis();
- p( "---got " + num + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---got " + num + " in " + timer.getElapsedTimeString() + " ---" );
}
/**
@@ -219,7 +219,7 @@ public class TestCacheAccess
}
else
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
try
{
final Object obj = cache_control.get( key );
@@ -232,8 +232,7 @@ public class TestCacheAccess
{
log.error( e );
}
- final long n_end = System.currentTimeMillis();
- p( "---got " + key + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---got " + key + " in " + timer.getElapsedTimeString() + " ---" );
}
}
@@ -275,7 +274,7 @@ public class TestCacheAccess
}
else
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
try
{
for ( int a = 0; a < num; a++ )
@@ -291,8 +290,7 @@ public class TestCacheAccess
{
log.error( e );
}
- final long n_end = System.currentTimeMillis();
- p( "---got " + num + " from group " + group + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---got " + num + " from group " + group + " in " + timer.getElapsedTimeString() + " ---" );
}
}
@@ -332,7 +330,7 @@ public class TestCacheAccess
}
else
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
try
{
final Object obj = group_cache_control.getFromGroup( key, group );
@@ -345,8 +343,7 @@ public class TestCacheAccess
{
log.error( e );
}
- final long n_end = System.currentTimeMillis();
- p( "---got " + key + " from group " + group + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---got " + key + " from group " + group + " in " + timer.getElapsedTimeString() + " ---" );
}
}
@@ -382,7 +379,7 @@ public class TestCacheAccess
}
else
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
try
{
final Map<String, String> results = cache_control.getMatching( pattern );
@@ -395,8 +392,7 @@ public class TestCacheAccess
{
log.error( e );
}
- final long n_end = System.currentTimeMillis();
- p( "---gotMatching [" + pattern + "] in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---gotMatching [" + pattern + "] in " + timer.getElapsedTimeString() + " ---" );
}
}
@@ -475,11 +471,9 @@ public class TestCacheAccess
}
else
{
-
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
cache_control.put( key, val );
- final long n_end = System.currentTimeMillis();
- p( "---put " + key + " | " + val + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---put " + key + " | " + val + " in " + timer.getElapsedTimeString() + " ---" );
}
}
@@ -514,14 +508,13 @@ public class TestCacheAccess
}
else
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
for ( int a = 0; a < num; a++ )
{
group_cache_control.putInGroup( "keygr" + a, group, "data " + a
+ " from putag ----asdfasfas-asfasfas-asfas in group " + group );
}
- final long n_end = System.currentTimeMillis();
- p( "---put " + num + " in group " + group + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---put " + num + " in group " + group + " in " + timer.getElapsedTimeString() + " ---" );
}
}
@@ -556,10 +549,9 @@ public class TestCacheAccess
}
else
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
group_cache_control.putInGroup( key, group, "data from putg ----asdfasfas-asfasfas-asfas in group " + group );
- final long n_end = System.currentTimeMillis();
- p( "---put " + key + " in group " + group + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---put " + key + " in group " + group + " in " + timer.getElapsedTimeString() + " ---" );
}
}
@@ -626,13 +618,12 @@ public class TestCacheAccess
{
try
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
for ( int n = 0; n < num; n++ )
{
cache_control.put( "key" + n, "data" + n + " put from ta = junk" );
}
- final long n_end = System.currentTimeMillis();
- p( "---put " + num + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---put " + num + " in " + timer.getElapsedTimeString() + " ---" );
}
catch ( final Exception e )
{
@@ -715,13 +706,12 @@ public class TestCacheAccess
{
try
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
for ( int n = 0; n < num; n++ )
{
cache_control.remove( "key" + n );
}
- final long n_end = System.currentTimeMillis();
- p( "---removed " + num + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---removed " + num + " in " + timer.getElapsedTimeString() + " ---" );
}
catch ( final Exception e )
{
@@ -760,7 +750,7 @@ public class TestCacheAccess
}
else if ( message.startsWith( "getAttributeNames" ) )
{
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
String groupName = null;
final StringTokenizer toke = new StringTokenizer( message );
int tcnt = 0;
@@ -774,13 +764,11 @@ public class TestCacheAccess
}
}
getAttributeNames( groupName );
- final long n_end = System.currentTimeMillis();
- p( "---got attrNames for " + groupName + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---got attrNames for " + groupName + " in " + timer.getElapsedTimeString() + " ---" );
}
else if ( message.startsWith( "shutDown" ) )
{
JCS.shutdown();
- //cache_control.dispose();
notDone = false;
//System.exit( -1 );
return;
@@ -839,7 +827,7 @@ public class TestCacheAccess
else
{
final int num = Integer.parseInt( numS.trim() );
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
for ( int n = 0; n < num; n++ )
{
final IElementAttributes attrp = cache_control.getDefaultElementAttributes();
@@ -847,8 +835,7 @@ public class TestCacheAccess
attrp.addElementEventHandler( hand );
cache_control.put( "key" + n, "data" + n + " put from ta = junk", attrp );
}
- final long n_end = System.currentTimeMillis();
- p( "---put " + num + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---put " + num + " in " + timer.getElapsedTimeString() + " ---" );
}
}
else if ( message.startsWith( "put" ) )
@@ -895,13 +882,12 @@ public class TestCacheAccess
{
final int num = Integer.parseInt( numS.trim() );
final IElementAttributes attrp = new ElementAttributes();
- final long n_start = System.currentTimeMillis();
+ final ElapsedTimer timer = new ElapsedTimer();
for ( int n = 0; n < num; n++ )
{
new ElementAttributes(attrp);
}
- final long n_end = System.currentTimeMillis();
- p( "---cloned attr " + num + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
+ p( "---cloned attr " + num + " in " + timer.getElapsedTimeString() + " ---" );
}
}
else if ( message.startsWith( "switch" ) )
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryServiceUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryServiceUnitTest.java
index bcf1eba6..b390a583 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryServiceUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryServiceUnitTest.java
@@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.time.Instant;
import java.util.ArrayList;
import org.apache.commons.jcs4.utils.serialization.StandardSerializer;
@@ -67,7 +68,7 @@ class UDPDiscoveryServiceUnitTest
discoveredService.setServiceAddress( host );
discoveredService.setCacheNames( new ArrayList<>() );
discoveredService.setServicePort( 1000 );
- discoveredService.setLastHearFromTime( 100 );
+ discoveredService.setLastHearFromTime(Instant.ofEpochMilli(100));
final ArrayList<String> differentCacheNames = new ArrayList<>();
differentCacheNames.add( "name1" );
@@ -75,7 +76,7 @@ class UDPDiscoveryServiceUnitTest
discoveredService2.setServiceAddress( host );
discoveredService2.setCacheNames( differentCacheNames );
discoveredService2.setServicePort( 1000 );
- discoveredService2.setLastHearFromTime( 500 );
+ discoveredService2.setLastHearFromTime(Instant.ofEpochMilli(500));
// DO WORK
service.addOrUpdateService( discoveredService );
@@ -119,13 +120,13 @@ class UDPDiscoveryServiceUnitTest
discoveredService.setServiceAddress( host );
discoveredService.setCacheNames( sameCacheNames );
discoveredService.setServicePort( 1000 );
- discoveredService.setLastHearFromTime( 100 );
+ discoveredService.setLastHearFromTime(Instant.ofEpochMilli(100));
final DiscoveredService discoveredService2 = new DiscoveredService();
discoveredService2.setServiceAddress( host );
discoveredService2.setCacheNames( sameCacheNames );
discoveredService2.setServicePort( 1000 );
- discoveredService2.setLastHearFromTime( 500 );
+ discoveredService2.setLastHearFromTime(Instant.ofEpochMilli(500));
// DO WORK
service.addOrUpdateService( discoveredService );
@@ -164,7 +165,7 @@ class UDPDiscoveryServiceUnitTest
discoveredService.setServiceAddress( host );
discoveredService.setCacheNames( new ArrayList<>() );
discoveredService.setServicePort( 1000 );
- discoveredService.setLastHearFromTime( 100 );
+ discoveredService.setLastHearFromTime(Instant.ofEpochMilli(100));
// DO WORK
service.addOrUpdateService( discoveredService );
@@ -184,7 +185,7 @@ class UDPDiscoveryServiceUnitTest
discoveredService.setServiceAddress( host );
discoveredService.setCacheNames( new ArrayList<>() );
discoveredService.setServicePort( 1000 );
- discoveredService.setLastHearFromTime( 100 );
+ discoveredService.setLastHearFromTime(Instant.ofEpochMilli(100));
service.addOrUpdateService( discoveredService );
diff --git a/src/site/xdoc/UpgradingFrom3x.xml b/src/site/xdoc/UpgradingFrom3x.xml
index 3a65fc2c..78d8ed91 100644
--- a/src/site/xdoc/UpgradingFrom3x.xml
+++ b/src/site/xdoc/UpgradingFrom3x.xml
@@ -89,12 +89,25 @@ jcs.auxiliary.blockDiskCache=org.apache.commons.jcs4.auxiliary.disk.block.BlockD
You should be aware that data previously saved to auxiliaries will be deleted
on startup.
</p>
+ <p>
+ JCS 4.0.0 tries to pull some long-standing configuration inconsistencies straight.
+ Note that configuration keys are case-sensitive. See the table of
+ renamed or removed configuration keys <a href="#ccb">below</a>.
+ </p>
+ <p>
+ Time related configuration items are now represented as <code>java.time.Duration</code>
+ internally. The corresponding configuration file properties are being parsed using
+ <code>Duration.parse()</code> and use the syntax documented
+ <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html#parse(java.lang.CharSequence)">here</a>.
+ If parsing fails, the value is assumed to be a millisecond duration. See the table of
+ affected configuration keys <a href="#ccb">below</a>.
+ </p>
</subsection>
<subsection name="Logging">
<p>
- JCS 4.0.0 uses a thin wrapper around the JDK9+ System.Logger interface for logging.
- By default, JCS uses java.util.logging as implementation. For a better readability
- we recommend to configure the logger formatting like this:
+ JCS 4.0.0 uses a thin wrapper around the JDK9+ <code>System.Logger</code> interface
+ for logging. By default, JCS uses <code>java.util.logging</code> as implementation.
+ For a better readability we recommend to configure the logger formatting like this:
</p>
<source><![CDATA[
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
@@ -121,8 +134,9 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
Please note that several internals structures are not exported intentionally.
</p>
</subsection>
- <subsection name="Changed Configuration Behavior">
+ <subsection name="Changed Configuration Behavior" id="ccb">
<p>
+ <b>Breaking:</b>
JCS 4.0.0 tries to pull some long-standing configuration inconsistencies straight.
Note that configuration keys are case-sensitive.
The following configuration keys have been renamed or removed:
@@ -179,6 +193,7 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
environments.
</p>
<p>
+ <b>Breaking:</b>
Time related configuration items are now represented as <code>java.time.Duration</code>
internally. The corresponding configuration file properties are being parsed using
<code>Duration.parse()</code> and use the syntax documented
@@ -202,6 +217,16 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n
<td>ShrinkerInterval</td>
<td>PT30s</td>
</tr>
+ <tr>
+ <td>Element configuration (ElementAttributes)</td>
+ <td>MaxLife</td>
+ <td>PT-0.001s (unlimited)</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>MaxIdleTime</td>
+ <td>PT-0.001s (unlimited)</td>
+ </tr>
<tr>
<td>Thread Pool Configuration (thread_pool, PoolConfiguration)</td>
<td>keepAliveTime</td>