Author: olamy
Date: Wed Dec 26 22:36:30 2012
New Revision: 1426071

URL: http://svn.apache.org/viewvc?rev=1426071&view=rev
Log:
maxElementsOnDisk configurable too

Modified:
    
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCache.java
    
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/Cache.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/AbstractCache.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/AbstractCache.java?rev=1426071&r1=1426070&r2=1426071&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCache.java
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/AbstractCache.java
 Wed Dec 26 22:36:30 2012
@@ -29,6 +29,10 @@ public abstract class AbstractCache
 
     private int timeToLiveSeconds = 0;
 
+    private int maxElementsInMemory = 0;
+
+    private int maxElementsOnDisk = 0;
+
     public int getTimeToIdleSeconds()
     {
         return timeToIdleSeconds;
@@ -48,4 +52,24 @@ public abstract class AbstractCache
     {
         this.timeToLiveSeconds = timeToLiveSeconds;
     }
+
+    public int getMaxElementsInMemory()
+    {
+        return maxElementsInMemory;
+    }
+
+    public void setMaxElementsInMemory( int maxElementsInMemory )
+    {
+        this.maxElementsInMemory = maxElementsInMemory;
+    }
+
+    public int getMaxElementsOnDisk()
+    {
+        return maxElementsOnDisk;
+    }
+
+    public void setMaxElementsOnDisk( int maxElementsOnDisk )
+    {
+        this.maxElementsOnDisk = maxElementsOnDisk;
+    }
 }

Modified: 
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/Cache.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/Cache.java?rev=1426071&r1=1426070&r2=1426071&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/Cache.java
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-cache/spring-cache-api/src/main/java/org/apache/archiva/redback/components/cache/Cache.java
 Wed Dec 26 22:36:30 2012
@@ -52,8 +52,8 @@ public interface Cache
      *
      * @param key   the key to fetch the contents of.
      * @param clazz class of object type to retrieve
-     * @since 2.1
      * @return the value of the key, or null if not found.
+     * @since 2.1
      */
     <T> T get( Object key, Class<T> clazz );
 
@@ -115,4 +115,12 @@ public interface Cache
 
     int getTimeToLiveSeconds();
 
+    int getMaxElementsInMemory();
+
+    void setMaxElementsInMemory( int maxElementsInMemory );
+
+    int getMaxElementsOnDisk();
+
+    void setMaxElementsOnDisk( int maxElementsOnDisk );
+
 }

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=1426071&r1=1426070&r2=1426071&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 Dec 26 22:36:30 2012
@@ -156,6 +156,11 @@ public class EhcacheCache
      */
     private boolean failOnDuplicateCache = false;
 
+    /**
+     * @since 2.1
+     */
+    private int maxElementsOnDisk;
+
     private boolean statisticsEnabled = true;
 
     private CacheManager cacheManager = CacheManager.getInstance();
@@ -197,7 +202,8 @@ public class EhcacheCache
                 isOverflowToDisk() ).diskStorePath( getDiskStorePath() 
).eternal( isEternal() ).timeToLiveSeconds(
                 getTimeToLiveSeconds() ).timeToIdleSeconds( 
getTimeToIdleSeconds() ).diskPersistent(
                 isDiskPersistent() ).diskExpiryThreadIntervalSeconds(
-                getDiskExpiryThreadIntervalSeconds() ).overflowToOffHeap( 
isOverflowToOffHeap() );
+                getDiskExpiryThreadIntervalSeconds() ).overflowToOffHeap( 
isOverflowToOffHeap() ).maxEntriesLocalDisk(
+                maxElementsOnDisk );
 
             if ( getMaxBytesLocalHeap() > 0 )
             {
@@ -377,6 +383,8 @@ public class EhcacheCache
         this.eternal = eternal;
     }
 
+
+
     public void setMaxElementsInMemory( int maxElementsInMemory )
     {
         this.maxElementsInMemory = maxElementsInMemory;
@@ -471,5 +479,18 @@ public class EhcacheCache
         this.maxBytesLocalOffHeap = maxBytesLocalOffHeap;
     }
 
+    public int getMaxElementsOnDisk()
+    {
+        return maxElementsOnDisk;
+    }
 
+    public void setMaxElementsOnDisk( int maxElementsOnDisk )
+    {
+        this.maxElementsOnDisk = maxElementsOnDisk;
+        if ( this.ehcache != null )
+        {
+            this.ehcache.getCacheConfiguration().setMaxElementsOnDisk( 
this.maxElementsOnDisk );
+            this.ehcache.getCacheConfiguration().maxEntriesLocalDisk( 
this.maxElementsOnDisk );
+        }
+    }
 }


Reply via email to