You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rm...@apache.org on 2014/05/12 21:23:19 UTC
svn commit: r1594064 -
/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
Author: rmannibucau
Date: Mon May 12 19:23:19 2014
New Revision: 1594064
URL: http://svn.apache.org/r1594064
Log:
don't call System.time methods if not needed
Modified:
commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java?rev=1594064&r1=1594063&r2=1594064&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java Mon May 12 19:23:19 2014
@@ -319,9 +319,6 @@ public class JCSCache<K, V> implements C
assertNotNull(key, "key");
assertNotNull(rawValue, "value");
- final boolean statisticsEnabled = config.isStatisticsEnabled();
- final long start = Times.now(false); // needed for access (eviction)
-
final ICacheElement<K, V> oldElt = delegate.get(key);
final V old = oldElt != null ? oldElt.getVal() : null;
@@ -332,6 +329,9 @@ public class JCSCache<K, V> implements C
final Duration duration = created ? expiryPolicy.getExpiryForCreation() : expiryPolicy.getExpiryForUpdate();
if (isNotZero(duration))
{
+ final boolean statisticsEnabled = config.isStatisticsEnabled();
+ final long start = Times.now(!statisticsEnabled);
+
final K jcsKey = storeByValue ? copy(serializer, manager.getClassLoader(), key) : key;
final ICacheElement<K, V> element = createElement(jcsKey, value, duration);
writer.write(new JCSEntry<K, V>(jcsKey, value));
@@ -497,7 +497,7 @@ public class JCSCache<K, V> implements C
final boolean propagateLoadException)
{
final boolean statisticsEnabled = config.isStatisticsEnabled();
- final long getStart = Times.now(false);
+ final long getStart = Times.now(!statisticsEnabled);
final ICacheElement<K, V> elt = delegate.get(key);
V v = elt != null ? elt.getVal() : null;
if (v == null && (config.isReadThrough() || forceDoLoad))