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/25 21:13:46 UTC
(commons-jcs) branch master updated (b0ed3b2d -> e1eed07c)
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 b0ed3b2d Javadoc
new f104e72d Fix naming
new 989340bd Update documentation
new 2ebe98bd Use Instant and Duration like anywhere else
new e1eed07c Better readability
The 4 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-core/pom.xml | 4 +
.../disk/jdbc/JDBCDataSourceFactoryUnitTest.java | 8 +-
commons-jcs4-jcache-extras/pom.xml | 4 +
commons-jcs4-jcache-openjpa/pom.xml | 4 +
commons-jcs4-jcache-tck/pom.xml | 4 +-
commons-jcs4-jcache/pom.xml | 4 +
.../commons/jcs4/jcache/EvictionListener.java | 2 +-
.../org/apache/commons/jcs4/jcache/JCSCache.java | 51 ++++++------
.../commons/jcs4/jcache/JCSCachingManager.java | 4 +-
.../apache/commons/jcs4/jcache/JCSListener.java | 19 ++---
.../org/apache/commons/jcs4/jcache/Statistics.java | 90 ++++++++++++++--------
.../commons/jcs4/jcache/TempStateCacheView.java | 4 +-
.../java/org/apache/commons/jcs4/jcache/Times.java | 37 ---------
.../jcs4/jcache/jmx/JCSCacheStatisticsMXBean.java | 8 +-
src/site/site.xml | 7 +-
src/site/xdoc/JCSandJCACHE.xml | 9 ++-
src/site/xdoc/MySQLDiskCacheProperties.xml | 2 +-
src/site/xdoc/getting_started/intro.xml | 4 +
src/site/xdoc/index.xml | 59 ++++++++++----
19 files changed, 180 insertions(+), 144 deletions(-)
delete mode 100644 commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Times.java
(commons-jcs) 03/04: Use Instant and Duration like anywhere else
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 2ebe98bd8310eae2e7e434e444ed47a7249ca025
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Wed Mar 25 21:59:13 2026 +0100
Use Instant and Duration like anywhere else
---
.../org/apache/commons/jcs4/jcache/JCSCache.java | 27 +++++-------
.../commons/jcs4/jcache/JCSCachingManager.java | 4 +-
.../apache/commons/jcs4/jcache/JCSListener.java | 19 +++-----
.../org/apache/commons/jcs4/jcache/Statistics.java | 51 ++++++++++++----------
.../java/org/apache/commons/jcs4/jcache/Times.java | 37 ----------------
.../jcs4/jcache/jmx/JCSCacheStatisticsMXBean.java | 8 ++--
6 files changed, 56 insertions(+), 90 deletions(-)
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 82e1efb5..1ad6c9fd 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
@@ -23,6 +23,7 @@ import static org.apache.commons.jcs4.jcache.serialization.Serializations.copy;
import java.io.Closeable;
import java.io.IOException;
+import java.time.Instant;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -291,7 +292,7 @@ public class JCSCache<K, V> implements Cache<K, V>
JMXs.unregister(cacheStatsObjectName);
}
- private V doGetControllingExpiry(final long getStart, final K key, final boolean updateAcess, final boolean forceDoLoad, final boolean skipLoad,
+ private V doGetControllingExpiry(final Instant getStart, final K key, final boolean updateAcess, final boolean forceDoLoad, final boolean skipLoad,
final boolean propagateLoadException)
{
final boolean statisticsEnabled = config.isStatisticsEnabled();
@@ -337,7 +338,7 @@ public class JCSCache<K, V> implements Cache<K, V>
}
if (statisticsEnabled && v != null)
{
- statistics.addGetTime(Times.now(false) - getStart);
+ statistics.addGetTime(java.time.Duration.between(getStart, Instant.now()));
}
return v;
}
@@ -407,7 +408,7 @@ public class JCSCache<K, V> implements Cache<K, V>
{
try
{
- final long now = Times.now(false);
+ final Instant now = Instant.now();
for (final K k : keys)
{
if (replaceExistingValues)
@@ -465,8 +466,7 @@ public class JCSCache<K, V> implements Cache<K, V>
{
assertNotClosed();
assertNotNull(key, "key");
- final long getStart = Times.now(false);
- return doGetControllingExpiry(getStart, key, true, false, false, true);
+ return doGetControllingExpiry(Instant.now(), key, true, false, false, true);
}
@Override
@@ -516,8 +516,7 @@ public class JCSCache<K, V> implements Cache<K, V>
assertNotClosed();
assertNotNull(key, "key");
assertNotNull(value, "value");
- final long getStart = Times.now(false);
- final V v = doGetControllingExpiry(getStart, key, false, false, true, false);
+ final V v = doGetControllingExpiry(Instant.now(), key, false, false, true, false);
put(key, value);
return v;
}
@@ -527,8 +526,7 @@ public class JCSCache<K, V> implements Cache<K, V>
{
assertNotClosed();
assertNotNull(key, "key");
- final long getStart = Times.now(false);
- final V v = doGetControllingExpiry(getStart, key, false, false, true, false);
+ final V v = doGetControllingExpiry(Instant.now(), key, false, false, true, false);
remove(key);
return v;
}
@@ -694,7 +692,7 @@ public class JCSCache<K, V> implements Cache<K, V>
if (isNotZero(duration))
{
final boolean statisticsEnabled = config.isStatisticsEnabled();
- final long start = Times.now(false);
+ final Instant start = Instant.now();
final K jcsKey = storeByValue ? copy(serializer, manager.getClassLoader(), key) : key;
IElementAttributes attributes = oldElt != null ? oldElt.elementAttributes() : delegate.getElementAttributes();
@@ -751,7 +749,7 @@ public class JCSCache<K, V> implements Cache<K, V>
if (statisticsEnabled)
{
statistics.increasePuts(1);
- statistics.addPutTime(Times.now(false) - start);
+ statistics.addPutTime(java.time.Duration.between(start, Instant.now()));
}
} else if (!created)
{
@@ -801,7 +799,7 @@ public class JCSCache<K, V> implements Cache<K, V>
assertNotNull(key, "key");
final boolean statisticsEnabled = config.isStatisticsEnabled();
- final long start = Times.now(!statisticsEnabled);
+ final Instant start = Instant.now();
writer.delete(key);
@@ -818,7 +816,7 @@ public class JCSCache<K, V> implements Cache<K, V>
if (remove && statisticsEnabled)
{
statistics.increaseRemovals(1);
- statistics.addRemoveTime(Times.now(false) - start);
+ statistics.addRemoveTime(java.time.Duration.between(start, Instant.now()));
}
return remove;
}
@@ -829,8 +827,7 @@ public class JCSCache<K, V> implements Cache<K, V>
assertNotClosed();
assertNotNull(key, "key");
assertNotNull(oldValue, "oldValue");
- final long getStart = Times.now(false);
- final V v = doGetControllingExpiry(getStart, key, false, false, false, false);
+ final V v = doGetControllingExpiry(Instant.now(), key, false, false, false, false);
if (oldValue.equals(v))
{
remove(key);
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 4db7e76c..4413ca89 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
@@ -302,7 +302,9 @@ public class JCSCachingManager implements CacheManager
{
assertNotClosed();
assertNotNull(cacheName, "cacheName");
- return (Cache<K, V>) doGetCache(cacheName, Object.class, Object.class);
+ @SuppressWarnings("unchecked") // common map for all caches
+ Cache<K, V> cache = (Cache<K, V>) doGetCache(cacheName, Object.class, Object.class);
+ return cache;
}
@Override
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSListener.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSListener.java
index a76e0cdc..752ed9d3 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSListener.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/JCSListener.java
@@ -19,7 +19,6 @@
package org.apache.commons.jcs4.jcache;
import java.io.Closeable;
-import java.util.ArrayList;
import java.util.List;
import javax.cache.configuration.CacheEntryListenerConfiguration;
@@ -70,7 +69,8 @@ public class JCSListener<K, V> implements Closeable
@Override
public void close()
{
- if (Closeable.class.isInstance(delegate)) {
+ if (Closeable.class.isInstance(delegate))
+ {
Closeable.class.cast(delegate);
}
}
@@ -82,18 +82,10 @@ public class JCSListener<K, V> implements Closeable
return events;
}
- final List<CacheEntryEvent<? extends K, ? extends V>> filtered = new ArrayList<>(
- events.size());
- for (final CacheEntryEvent<? extends K, ? extends V> event : events)
- {
- if (filter.evaluate(event))
- {
- filtered.add(event);
- }
- }
- return filtered;
+ return events.stream().filter(filter::evaluate).toList();
}
+ @SuppressWarnings("unchecked")
public void onCreated(final List<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException
{
if (create)
@@ -102,6 +94,7 @@ public class JCSListener<K, V> implements Closeable
}
}
+ @SuppressWarnings("unchecked")
public void onExpired(final List<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException
{
if (expire)
@@ -110,6 +103,7 @@ public class JCSListener<K, V> implements Closeable
}
}
+ @SuppressWarnings("unchecked")
public void onRemoved(final List<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException
{
if (remove)
@@ -118,6 +112,7 @@ public class JCSListener<K, V> implements Closeable
}
}
+ @SuppressWarnings("unchecked")
public void onUpdated(final List<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException
{
if (update)
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java
index 5863f364..2f361614 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java
@@ -18,10 +18,15 @@
*/
package org.apache.commons.jcs4.jcache;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
public class Statistics
{
+ private static final Duration MAX_DURATION = ChronoUnit.FOREVER.getDuration();
+
private volatile boolean active = true;
private final AtomicLong removals = new AtomicLong();
@@ -30,21 +35,21 @@ public class Statistics
private final AtomicLong hits = new AtomicLong();
private final AtomicLong misses = new AtomicLong();
private final AtomicLong evictions = new AtomicLong();
- private final AtomicLong putTimeTaken = new AtomicLong();
- private final AtomicLong getTimeTaken = new AtomicLong();
- private final AtomicLong removeTimeTaken = new AtomicLong();
+ private final AtomicReference<Duration> putTimeTaken = new AtomicReference<Duration>(Duration.ZERO);
+ private final AtomicReference<Duration> getTimeTaken = new AtomicReference<Duration>(Duration.ZERO);
+ private final AtomicReference<Duration> removeTimeTaken = new AtomicReference<Duration>(Duration.ZERO);
- public void addGetTime(final long duration)
+ public void addGetTime(final Duration duration)
{
increment(duration, getTimeTaken);
}
- public void addPutTime(final long duration)
+ public void addPutTime(final Duration duration)
{
increment(duration, putTimeTaken);
}
- public void addRemoveTime(final long duration)
+ public void addRemoveTime(final Duration duration)
{
increment(duration, removeTimeTaken);
}
@@ -74,17 +79,17 @@ public class Statistics
return removals.get();
}
- public long getTimeTakenForGets()
+ public Duration getTimeTakenForGets()
{
return getTimeTaken.get();
}
- public long getTimeTakenForPuts()
+ public Duration getTimeTakenForPuts()
{
return putTimeTaken.get();
}
- public long getTimeTakenForRemovals()
+ public Duration getTimeTakenForRemovals()
{
return removeTimeTaken.get();
}
@@ -128,22 +133,24 @@ public class Statistics
counter.addAndGet(number);
}
- private void increment(final long duration, final AtomicLong counter)
+ private void increment(final Duration duration, final AtomicReference<Duration> counter)
{
if (!active)
{
return;
}
- if (counter.get() < Long.MAX_VALUE - duration)
- {
- counter.addAndGet(duration);
- }
- else
- {
- reset();
- counter.set(duration);
- }
+ counter.accumulateAndGet(duration, (u, v) -> {
+ if (u.compareTo(MAX_DURATION.minus(v)) < 0)
+ {
+ return u.plus(v);
+ }
+ else
+ {
+ reset();
+ return v;
+ }
+ });
}
public void reset()
@@ -154,9 +161,9 @@ public class Statistics
expiries.set(0);
hits.set(0);
evictions.set(0);
- getTimeTaken.set(0);
- putTimeTaken.set(0);
- removeTimeTaken.set(0);
+ getTimeTaken.set(Duration.ZERO);
+ putTimeTaken.set(Duration.ZERO);
+ removeTimeTaken.set(Duration.ZERO);
}
public void setActive(final boolean active)
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Times.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Times.java
deleted file mode 100644
index 01b622d3..00000000
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Times.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.commons.jcs4.jcache;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Times
-{
- public static long now(final boolean ignore)
- {
- if (ignore)
- {
- return -1;
- }
- return System.nanoTime() / 1000;
- }
-
- private Times()
- {
- // no-op
- }
-}
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/jmx/JCSCacheStatisticsMXBean.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/jmx/JCSCacheStatisticsMXBean.java
index c612c86d..d9045aa1 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/jmx/JCSCacheStatisticsMXBean.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/jmx/JCSCacheStatisticsMXBean.java
@@ -18,6 +18,8 @@
*/
package org.apache.commons.jcs4.jcache.jmx;
+import java.time.Duration;
+
import javax.cache.management.CacheStatisticsMXBean;
import org.apache.commons.jcs4.jcache.Statistics;
@@ -31,14 +33,14 @@ public class JCSCacheStatisticsMXBean implements CacheStatisticsMXBean
this.statistics = stats;
}
- private float averageTime(final long timeTaken)
+ private float averageTime(final Duration timeTaken)
{
final long gets = getCacheGets();
- if (timeTaken == 0 || gets == 0)
+ if (timeTaken.isZero() || gets == 0)
{
return 0;
}
- return timeTaken / gets;
+ return timeTaken.toMillis() / (float) gets;
}
@Override
(commons-jcs) 04/04: Better readability
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 e1eed07c7f484b07c9f6c2ca66b6ef61bdbca484
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Wed Mar 25 22:13:13 2026 +0100
Better readability
---
.../commons/jcs4/jcache/EvictionListener.java | 2 +-
.../org/apache/commons/jcs4/jcache/JCSCache.java | 24 ++++++-------
.../org/apache/commons/jcs4/jcache/Statistics.java | 39 +++++++++++++++-------
.../commons/jcs4/jcache/TempStateCacheView.java | 4 +--
4 files changed, 42 insertions(+), 27 deletions(-)
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/EvictionListener.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/EvictionListener.java
index 9e1a1a3b..91ddaae4 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/EvictionListener.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/EvictionListener.java
@@ -39,7 +39,7 @@ public class EvictionListener implements IElementEventHandler
case EXCEEDED_MAXLIFE_ONREQUEST:
case EXCEEDED_IDLETIME_ONREQUEST:
case EXCEEDED_IDLETIME_BACKGROUND:
- stats.increaseEvictions(1);
+ stats.incrementEvictions();
break;
default:
break;
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 1ad6c9fd..0798ae50 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
@@ -309,11 +309,11 @@ public class JCSCache<K, V> implements Cache<K, V>
{
if (v != null)
{
- statistics.increaseHits(1);
+ statistics.incrementHits();
}
else
{
- statistics.increaseMisses(1);
+ statistics.incrementMisses();
}
}
@@ -355,11 +355,11 @@ public class JCSCache<K, V> implements Cache<K, V>
{
if (containsKey(key))
{
- statistics.increaseHits(1);
+ statistics.incrementHits();
}
else
{
- statistics.increaseMisses(1);
+ statistics.incrementMisses();
}
}
return entryProcessor.process(new JCSMutableEntry<>(view, key), arguments);
@@ -550,14 +550,14 @@ public class JCSCache<K, V> implements Cache<K, V>
}
else if (statisticsEnabled)
{
- statistics.increaseHits(1);
+ statistics.incrementHits();
}
put(key, value);
return oldValue;
}
if (statisticsEnabled)
{
- statistics.increaseMisses(1);
+ statistics.incrementMisses();
}
return null;
}
@@ -748,7 +748,7 @@ public class JCSCache<K, V> implements Cache<K, V>
if (statisticsEnabled)
{
- statistics.increasePuts(1);
+ statistics.incrementPuts();
statistics.addPutTime(java.time.Duration.between(start, Instant.now()));
}
} else if (!created)
@@ -815,7 +815,7 @@ public class JCSCache<K, V> implements Cache<K, V>
}
if (remove && statisticsEnabled)
{
- statistics.increaseRemovals(1);
+ statistics.incrementRemovals();
statistics.addRemoveTime(java.time.Duration.between(start, Instant.now()));
}
return remove;
@@ -873,14 +873,14 @@ public class JCSCache<K, V> implements Cache<K, V>
{
if (statisticsEnabled)
{
- statistics.increaseHits(1);
+ statistics.incrementHits();
}
put(key, value);
return true;
}
if (statisticsEnabled)
{
- statistics.increaseMisses(1);
+ statistics.incrementMisses();
}
return false;
}
@@ -899,7 +899,7 @@ public class JCSCache<K, V> implements Cache<K, V>
V value = elt.value();
if (value != null && statisticsEnabled)
{
- statistics.increaseHits(1);
+ statistics.incrementHits();
}
if (value == null && config.isReadThrough())
{
@@ -928,7 +928,7 @@ public class JCSCache<K, V> implements Cache<K, V>
}
else if (statisticsEnabled)
{
- statistics.increaseMisses(1);
+ statistics.incrementMisses();
}
return false;
}
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java
index 2f361614..1ab4692c 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/Statistics.java
@@ -94,34 +94,49 @@ public class Statistics
return removeTimeTaken.get();
}
- public void increaseEvictions(final long number)
+ public void incrementEvictions()
{
- increment(evictions, number);
+ increment(evictions, 1L);
}
- public void increaseExpiries(final long number)
+ public void incrementHits()
{
- increment(expiries, number);
+ increment(hits, 1L);
}
- public void increaseHits(final long number)
+ public void decrementHits()
{
- increment(hits, number);
+ increment(hits, -1L);
}
- public void increaseMisses(final long number)
+ public void incrementMisses()
{
- increment(misses, number);
+ increment(misses, 1L);
}
- public void increasePuts(final long number)
+ public void decrementMisses()
{
- increment(puts, number);
+ increment(misses, -1L);
}
- public void increaseRemovals(final long number)
+ public void incrementPuts()
{
- increment(removals, number);
+ increment(puts, 1L);
+ }
+
+ public void decrementPuts()
+ {
+ increment(puts, -1L);
+ }
+
+ public void incrementRemovals()
+ {
+ increment(removals, 1L);
+ }
+
+ public void decrementRemovals()
+ {
+ increment(removals, -1L);
}
private void increment(final AtomicLong counter, final long number)
diff --git a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/TempStateCacheView.java b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/TempStateCacheView.java
index 4c707050..6f1c1454 100644
--- a/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/TempStateCacheView.java
+++ b/commons-jcs4-jcache/src/main/java/org/apache/commons/jcs4/jcache/TempStateCacheView.java
@@ -99,11 +99,11 @@ public class TempStateCacheView<K, V> implements Cache<K, V>
final Statistics statistics = cache.getStatistics();
if (cache.containsKey(key))
{
- statistics.increaseHits(-1);
+ statistics.decrementHits();
}
else
{
- statistics.increaseMisses(-1);
+ statistics.decrementMisses();
}
}
return cache.get(key);
(commons-jcs) 02/04: Update documentation
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 989340bde3b2f97b162b53ac4b28bbd7d5d28b64
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Wed Mar 25 21:58:37 2026 +0100
Update documentation
---
commons-jcs4-core/pom.xml | 4 +++
commons-jcs4-jcache-extras/pom.xml | 4 +++
commons-jcs4-jcache-openjpa/pom.xml | 4 +++
commons-jcs4-jcache-tck/pom.xml | 4 ++-
commons-jcs4-jcache/pom.xml | 4 +++
src/site/site.xml | 7 +++-
src/site/xdoc/JCSandJCACHE.xml | 9 +++--
src/site/xdoc/getting_started/intro.xml | 4 +++
src/site/xdoc/index.xml | 59 +++++++++++++++++++++++----------
9 files changed, 77 insertions(+), 22 deletions(-)
diff --git a/commons-jcs4-core/pom.xml b/commons-jcs4-core/pom.xml
index 9c803436..24c4a072 100644
--- a/commons-jcs4-core/pom.xml
+++ b/commons-jcs4-core/pom.xml
@@ -31,6 +31,10 @@
<packaging>jar</packaging>
<name>Apache Commons JCS :: Core</name>
+ <description>
+ This module contains the core implementation of Apache Commons JCS.
+ It consists of multiple memory cache implementations and various auxiliary plugins.
+ </description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-jcs.git</connection>
diff --git a/commons-jcs4-jcache-extras/pom.xml b/commons-jcs4-jcache-extras/pom.xml
index 4d48f836..66914213 100644
--- a/commons-jcs4-jcache-extras/pom.xml
+++ b/commons-jcs4-jcache-extras/pom.xml
@@ -26,6 +26,10 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>commons-jcs4-jcache-extras</artifactId>
<name>Apache Commons JCS :: JCache Extras</name>
+ <description>
+ This module contains some extensions to the JSR-107 JCache implementation.
+ </description>
+
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-jcs.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/commons-jcs.git</developerConnection>
diff --git a/commons-jcs4-jcache-openjpa/pom.xml b/commons-jcs4-jcache-openjpa/pom.xml
index f57ff87d..fe07db8a 100644
--- a/commons-jcs4-jcache-openjpa/pom.xml
+++ b/commons-jcs4-jcache-openjpa/pom.xml
@@ -27,6 +27,10 @@
<artifactId>commons-jcs4-jcache-openjpa</artifactId>
<name>Apache Commons JCS :: JCache OpenJPA</name>
+ <description>
+ This module contains an implementation of a DataCache for OpenJPA based on
+ the JSR-107 JCache implementation.
+ </description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-jcs.git</connection>
diff --git a/commons-jcs4-jcache-tck/pom.xml b/commons-jcs4-jcache-tck/pom.xml
index 3703891e..17ee3dbd 100644
--- a/commons-jcs4-jcache-tck/pom.xml
+++ b/commons-jcs4-jcache-tck/pom.xml
@@ -34,8 +34,10 @@
-->
<artifactId>commons-jcs4-jcache-tck</artifactId>
-
<name>Apache Commons JCS :: JCache TCK</name>
+ <description>
+ This module runs the JSR-107 TCK for JCache.
+ </description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-jcs.git</connection>
diff --git a/commons-jcs4-jcache/pom.xml b/commons-jcs4-jcache/pom.xml
index fe5c98ff..c822d952 100644
--- a/commons-jcs4-jcache/pom.xml
+++ b/commons-jcs4-jcache/pom.xml
@@ -29,6 +29,10 @@
<artifactId>commons-jcs4-jcache</artifactId>
<name>Apache Commons JCS :: JCache</name>
+ <description>
+ This module contains the JSR-107 API (version ${jsr107.api.version}) implementation of
+ Apache Commons JCS.
+ </description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-jcs.git</connection>
diff --git a/src/site/site.xml b/src/site/site.xml
index 9a3df6ea..c72aeb15 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -73,7 +73,12 @@
</item>
</menu>
- <menu ref="modules" />
+ <menu name="Modules">
+ <item name="Core" href="commons-jcs4-core/index.html"/>
+ <item name="JCache" href="commons-jcs4-jcache/index.html"/>
+ <item name="JCache Extras" href="commons-jcs4-jcache-extras/index.html"/>
+ <item name="JCache OpenJPA" href="commons-jcs4-jcache-openjpa/index.html"/>
+ </menu>
</body>
diff --git a/src/site/xdoc/JCSandJCACHE.xml b/src/site/xdoc/JCSandJCACHE.xml
index 50898eb9..f7f24904 100644
--- a/src/site/xdoc/JCSandJCACHE.xml
+++ b/src/site/xdoc/JCSandJCACHE.xml
@@ -28,9 +28,12 @@
<body>
<section name="JCACHE (JSR-107)">
<p>
- Since version 2.x, Apache Commons JCS implements
- JCache specification (and a few more providing some basic utilities
- in its extras module and a basic integration with Apache OpenJPA).
+ Since version 2.x, Apache Commons JCS implements the
+ <a href="commons-jcs4-jcache/index.html">JCache specification</a>
+ (and a few more providing some basic utilities in its
+ <a href="commons-jcs4-jcache-extras/index.html">extras module</a>
+ and a <a href="commons-jcs4-jcache-openjpa/index.html">basic integration</a>
+ with Apache OpenJPA).
</p>
<p>
The next section is about the main differences between the JCache design and the original JCS one.
diff --git a/src/site/xdoc/getting_started/intro.xml b/src/site/xdoc/getting_started/intro.xml
index 5fb5248e..0f5c4ebb 100644
--- a/src/site/xdoc/getting_started/intro.xml
+++ b/src/site/xdoc/getting_started/intro.xml
@@ -91,6 +91,10 @@
</section>
<section name="STEP 3: Get the Required Dependencies">
+ <p>
+ Beginning with version 3.0 the core of JCS has no mandatory external
+ dependencies.
+ </p>
<p>
Beginning with version 2.0 the core of JCS (the LRU memory
cache, the indexed disk cache, the TCP lateral, and the
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 0c8c0566..bd90bb5c 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -57,6 +57,9 @@
<li>Key pattern matching retrieval</li>
<li>Network efficient multi-key retrieval</li>
</ul>
+ <p> JCS 4.x works on JDK versions 17 and up. It has no
+ mandatory external dependencies. See the document about
+ <a href="UpgradingFrom3x.html">upgrading</a>.</p>
<p> JCS 3.x works on JDK versions 1.8 and up. It has no
mandatory external dependencies. See the document about
<a href="UpgradingFrom2x.html">upgrading</a>.</p>
@@ -89,23 +92,45 @@
.
</p>
</subsection>
- <subsection name="Indexed Disk Cache">
- <p>
- The
- <a href="IndexedDiskAuxCache.html">Indexed Disk Cache</a>
- is a fast, reliable, and
- <a href="IndexedDiskCacheProperties.html"> highly configurable</a>
- swap for cached data. The indexed disk cache follows the fastest
- pattern for disk swapping. Cache elements are written to disk via a
- continuous queue-based process. The length of the item is stored in
- the first few bytes of the entry. The offset is stored in memory
- and can be reference via the key. When items are removed from the
- disk cache, the location and size are recorded and reused when
- possible. Every aspect of the disk cache is configurable, and a
- thread pool can be used to reduce the number of queue worker
- threads across the system.
- </p>
- </subsection>
+ <subsection name="Indexed Disk Cache">
+ <p>
+ The
+ <a href="IndexedDiskAuxCache.html">Indexed Disk Cache</a>
+ is a fast, reliable, and
+ <a href="IndexedDiskCacheProperties.html"> highly configurable</a>
+ swap for cached data. The indexed disk cache follows the fastest
+ pattern for disk swapping. Cache elements are written to disk via a
+ continuous queue-based process. The length of the item is stored in
+ the first few bytes of the entry. The offset is stored in memory
+ and can be reference via the key. When items are removed from the
+ disk cache, the location and size are recorded and reused when
+ possible. Every aspect of the disk cache is configurable, and a
+ thread pool can be used to reduce the number of queue worker
+ threads across the system.
+ </p>
+ </subsection>
+ <subsection name="Block Disk Cache">
+ <p>
+ The
+ <a href="BlockDiskCache.html">Block Disk Cache</a>
+ is a fast and reliable swap for cached data, similar to the
+ Indexed Disk Cache.
+ </p>
+ <p>
+ The Block Disk Cache stores cached values on disk
+ in a group of fixed size blocks, whereas the Indexed
+ Disk Cache writes items to disk in one chunk.
+ </p>
+ <p>
+ The Block Disk Cache has advantages over the normal
+ indexed model for regions where the size of the items
+ varies. Since all the blocks are the same size, the
+ recycle bin is very simple. It is just a list of block
+ numbers. Also, the Block Disk Cache will never need to
+ be optimized. Once the maximum number of keys is
+ reached, blocks will be reused.
+ </p>
+ </subsection>
<subsection name="JDBC Disk Cache">
<p>
The
(commons-jcs) 01/04: Fix naming
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 f104e72d93e1ce5c8e02652e95e743b13db7387e
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Wed Mar 25 18:49:27 2026 +0100
Fix naming
---
.../jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java | 8 ++++----
src/site/xdoc/MySQLDiskCacheProperties.xml | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
index 5de969f8..c001032d 100644
--- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
+++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
@@ -137,7 +137,7 @@ class JDBCDataSourceFactoryUnitTest
assertNotNull( spds, "Should have a data source class" );
// VERIFY
- assertEquals( maxTotal, spds.getMaxTotal(), "Wrong maxActive value" );
+ assertEquals( maxTotal, spds.getMaxTotal(), "Wrong maxTotal value" );
}
/**
@@ -183,7 +183,7 @@ class JDBCDataSourceFactoryUnitTest
final String url = "adfads";
final String userName = "zvzvz";
final String password = "qewrrewq";
- final int maxActive = 10;
+ final int maxTotal = 10;
final String driverClassName = "org.hsqldb.jdbcDriver";
final Properties props = new Properties();
@@ -193,7 +193,7 @@ class JDBCDataSourceFactoryUnitTest
props.put( prefix + ".url", url );
props.put( prefix + ".userName", userName );
props.put( prefix + ".password", password );
- props.put( prefix + ".maxActive", String.valueOf( maxActive ) );
+ props.put( prefix + ".maxTotal", String.valueOf( maxTotal ) );
props.put( prefix + ".driverClassName", driverClassName );
final JDBCDiskCacheFactory factory = new JDBCDiskCacheFactory();
@@ -211,7 +211,7 @@ class JDBCDataSourceFactoryUnitTest
// VERIFY
assertEquals( poolName, spds.getDescription(), "Wrong pool name" );
- assertEquals( maxActive, spds.getMaxTotal(), "Wrong maxActive value" );
+ assertEquals( maxTotal, spds.getMaxTotal(), "Wrong maxTotal value" );
}
}
diff --git a/src/site/xdoc/MySQLDiskCacheProperties.xml b/src/site/xdoc/MySQLDiskCacheProperties.xml
index f1f38eb6..82454617 100644
--- a/src/site/xdoc/MySQLDiskCacheProperties.xml
+++ b/src/site/xdoc/MySQLDiskCacheProperties.xml
@@ -166,7 +166,7 @@ jcs.auxiliary.MYSQL.attributes.url=jdbc:hsqldb:target/cache_hsql_db
jcs.auxiliary.MYSQL.attributes.driverClassName=org.hsqldb.jdbcDriver
jcs.auxiliary.MYSQL.attributes.tableName=JCS_STORE_MYSQL
jcs.auxiliary.MYSQL.attributes.testBeforeInsert=false
-jcs.auxiliary.MYSQL.attributes.maxActive=15
+jcs.auxiliary.MYSQL.attributes.maxTotal=15
jcs.auxiliary.MYSQL.attributes.allowRemoveAll=true
jcs.auxiliary.MYSQL.attributes.MaxPurgatorySize=10000000
jcs.auxiliary.MYSQL.attributes.optimizationSchedule=12:34:56,02:34:54