You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/06/27 16:26:50 UTC
svn commit: r1354528 - in
/archiva/redback/redback-components/trunk/spring-cache:
spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/
spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/impl/
spring-cache-...
Author: olamy
Date: Wed Jun 27 14:26:49 2012
New Revision: 1354528
URL: http://svn.apache.org/viewvc?rev=1354528&view=rev
Log:
cache statistics can return inmemory size btw not implemented by all cache implementations
Modified:
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCacheStatistics.java
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/CacheStatistics.java
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/impl/NoCacheCache.java
archiva/redback/redback-components/trunk/spring-cache/spring-cache-providers/spring-cache-ehcache/src/main/java/org/apache/archiva/redback/components/cache/ehcache/EhcacheCache.java
Modified: archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCacheStatistics.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCacheStatistics.java?rev=1354528&r1=1354527&r2=1354528&view=diff
==============================================================================
--- archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCacheStatistics.java (original)
+++ archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCacheStatistics.java Wed Jun 27 14:26:49 2012
@@ -70,4 +70,11 @@ public abstract class AbstractCacheStati
this.cacheMiss = 0;
}
+ /**
+ * @return default implementation return 0
+ */
+ public long inMemorySize()
+ {
+ return 0;
+ }
}
Modified: archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/CacheStatistics.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/CacheStatistics.java?rev=1354528&r1=1354527&r2=1354528&view=diff
==============================================================================
--- archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/CacheStatistics.java (original)
+++ archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/CacheStatistics.java Wed Jun 27 14:26:49 2012
@@ -58,4 +58,11 @@ public interface CacheStatistics
* Clear the statistics of the cache.
*/
void clear();
+
+ /**
+ * return the memory used by the cache in memory
+ * <b>can be not implemented by some caches implementation</b>
+ * @since 2.0
+ */
+ long inMemorySize();
}
Modified: archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/impl/NoCacheCache.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/impl/NoCacheCache.java?rev=1354528&r1=1354527&r2=1354528&view=diff
==============================================================================
--- archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/impl/NoCacheCache.java (original)
+++ archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/impl/NoCacheCache.java Wed Jun 27 14:26:49 2012
@@ -63,6 +63,11 @@ public class NoCacheCache
{
return 0;
}
+
+ public long inMemorySize()
+ {
+ return 0;
+ }
}
private CacheStatistics stats = new NoStats();
Modified: archiva/redback/redback-components/trunk/spring-cache/spring-cache-providers/spring-cache-ehcache/src/main/java/org/apache/archiva/redback/components/cache/ehcache/EhcacheCache.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-cache/spring-cache-providers/spring-cache-ehcache/src/main/java/org/apache/archiva/redback/components/cache/ehcache/EhcacheCache.java?rev=1354528&r1=1354527&r2=1354528&view=diff
==============================================================================
--- archiva/redback/redback-components/trunk/spring-cache/spring-cache-providers/spring-cache-ehcache/src/main/java/org/apache/archiva/redback/components/cache/ehcache/EhcacheCache.java (original)
+++ archiva/redback/redback-components/trunk/spring-cache/spring-cache-providers/spring-cache-ehcache/src/main/java/org/apache/archiva/redback/components/cache/ehcache/EhcacheCache.java Wed Jun 27 14:26:49 2012
@@ -31,19 +31,17 @@ import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
/**
- * EhcacheCache
- * configuration document available <a href="http://www.ehcache.org/documentation/configuration/index">EhcacheUserGuide</a>
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * EhcacheCache
+ * configuration document available <a href="http://www.ehcache.org/documentation/configuration/index">EhcacheUserGuide</a>
*
- *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*/
public class EhcacheCache
implements org.apache.archiva.redback.components.cache.Cache
{
-
- private Logger log = LoggerFactory.getLogger( getClass() );
-
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
class Stats
implements CacheStatistics
{
@@ -80,23 +78,24 @@ public class EhcacheCache
return ehcache.getMemoryStoreSize() + ehcache.getDiskStoreSize();
}
+ public long inMemorySize()
+ {
+ return ehcache.calculateInMemorySize();
+ }
}
/**
* how often to run the disk store expiry thread. A large number of 120 seconds plus is recommended
- *
*/
private long diskExpiryThreadIntervalSeconds = 600;
/**
* Whether to persist the cache to disk between JVM restarts.
- *
*/
private boolean diskPersistent = true;
/**
* Location on disk for the ehcache store.
- *
*/
private String diskStorePath = System.getProperty( "java.io.tmpdir" ) + "/ehcache";
@@ -122,7 +121,6 @@ public class EhcacheCache
/**
* Flag indicating when to use the disk store.
- *
*/
private boolean overflowToDisk = false;
@@ -135,10 +133,10 @@ public class EhcacheCache
*
*/
private int timeToLiveSeconds = 300;
-
+
/**
*
- */
+ */
private boolean failOnDuplicateCache = false;
private boolean statisticsEnabled = true;
@@ -175,17 +173,17 @@ public class EhcacheCache
}
}
- if (!cacheExists)
+ if ( !cacheExists )
{
- ehcache = new Cache( getName(), getMaxElementsInMemory(), getMemoryStoreEvictionPolicy(), isOverflowToDisk(),
- getDiskStorePath(), isEternal(), getTimeToLiveSeconds(), getTimeToIdleSeconds(),
- isDiskPersistent(), getDiskExpiryThreadIntervalSeconds(), null );
-
+ ehcache =
+ new Cache( getName(), getMaxElementsInMemory(), getMemoryStoreEvictionPolicy(), isOverflowToDisk(),
+ getDiskStorePath(), isEternal(), getTimeToLiveSeconds(), getTimeToIdleSeconds(),
+ isDiskPersistent(), getDiskExpiryThreadIntervalSeconds(), null );
cacheManager.addCache( ehcache );
ehcache.setStatisticsEnabled( statisticsEnabled );
}
- }
+ }
public void dispose()
{
@@ -206,7 +204,7 @@ public class EhcacheCache
public Object get( Object key )
{
- if (key == null)
+ if ( key == null )
{
return null;
}
@@ -287,7 +285,7 @@ public class EhcacheCache
{
ehcache.put( new Element( key, value ) );
}
-
+
public Object put( Object key, Object value )
{
// Multiple steps done to satisfy Cache API requirement for Previous object return.