Author: olamy
Date: Wed Jun 27 15:15:10 2012
New Revision: 1354574
URL: http://svn.apache.org/viewvc?rev=1354574&view=rev
Log:
more configuration options for ehcache implementation
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
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=1354574&r1=1354573&r2=1354574&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 15:15:10 2012
@@ -23,6 +23,7 @@ import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import net.sf.ehcache.Status;
+import net.sf.ehcache.config.CacheConfiguration;
import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
import org.apache.archiva.redback.components.cache.CacheStatistics;
import org.slf4j.Logger;
@@ -135,6 +136,21 @@ public class EhcacheCache
private int timeToLiveSeconds = 300;
/**
+ * @since 2.0
+ */
+ private boolean overflowToOffHeap = false;
+
+ /**
+ * @since 2.0
+ */
+ private long maxBytesLocalHeap;
+
+ /**
+ * @since 2.0
+ */
+ private long maxBytesLocalOffHeap;
+
+ /**
*
*/
private boolean failOnDuplicateCache = false;
@@ -175,10 +191,23 @@ public class EhcacheCache
if ( !cacheExists )
{
- ehcache =
- new Cache( getName(), getMaxElementsInMemory(),
getMemoryStoreEvictionPolicy(), isOverflowToDisk(),
- getDiskStorePath(), isEternal(),
getTimeToLiveSeconds(), getTimeToIdleSeconds(),
- isDiskPersistent(),
getDiskExpiryThreadIntervalSeconds(), null );
+ CacheConfiguration cacheConfiguration = new
CacheConfiguration().name( getName() ).maxEntriesLocalHeap(
+ getMaxElementsInMemory() ).memoryStoreEvictionPolicy(
getMemoryStoreEvictionPolicy() ).overflowToDisk(
+ isOverflowToDisk() ).diskStorePath( getDiskStorePath()
).eternal( isEternal() ).timeToLiveSeconds(
+ getTimeToLiveSeconds() ).timeToIdleSeconds(
getTimeToIdleSeconds() ).diskPersistent(
+ isDiskPersistent() ).diskExpiryThreadIntervalSeconds(
+ getDiskExpiryThreadIntervalSeconds() ).overflowToOffHeap(
isOverflowToOffHeap() );
+
+ if ( getMaxBytesLocalHeap() > 0 )
+ {
+ cacheConfiguration.setMaxBytesLocalHeap(
getMaxBytesLocalHeap() );
+ }
+ if ( getMaxBytesLocalOffHeap() > 0 )
+ {
+ cacheConfiguration.setMaxBytesLocalOffHeap(
getMaxBytesLocalOffHeap() );
+ }
+
+ ehcache = new Cache( cacheConfiguration );
cacheManager.addCache( ehcache );
ehcache.setStatisticsEnabled( statisticsEnabled );
@@ -384,4 +413,34 @@ public class EhcacheCache
{
this.failOnDuplicateCache = failOnDuplicateCache;
}
+
+ public boolean isOverflowToOffHeap()
+ {
+ return overflowToOffHeap;
+ }
+
+ public void setOverflowToOffHeap( boolean overflowToOffHeap )
+ {
+ this.overflowToOffHeap = overflowToOffHeap;
+ }
+
+ public long getMaxBytesLocalHeap()
+ {
+ return maxBytesLocalHeap;
+ }
+
+ public void setMaxBytesLocalHeap( long maxBytesLocalHeap )
+ {
+ this.maxBytesLocalHeap = maxBytesLocalHeap;
+ }
+
+ public long getMaxBytesLocalOffHeap()
+ {
+ return maxBytesLocalOffHeap;
+ }
+
+ public void setMaxBytesLocalOffHeap( long maxBytesLocalOffHeap )
+ {
+ this.maxBytesLocalOffHeap = maxBytesLocalOffHeap;
+ }
}