asmuts 02/02/18 10:17:20
Modified: src/java/org/apache/stratum/jcs/engine/behavior
ICompositeCacheAttributes.java
src/java/org/apache/stratum/jcs/engine
ElementAttributes.java
CompositeCacheAttributes.java
src/java/org/apache/stratum/jcs/engine/control Cache.java
Log:
added to composite cache attributes
Revision Changes Path
1.5 +52 -1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICompositeCacheAttributes.java
Index: ICompositeCacheAttributes.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/behavior/ICompositeCacheAttributes.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ICompositeCacheAttributes.java 16 Feb 2002 02:37:22 -0000 1.4
+++ ICompositeCacheAttributes.java 18 Feb 2002 18:17:20 -0000 1.5
@@ -114,8 +114,59 @@
public String getMemoryCacheName();
+ /**
+ * Whether the memory cache should perform background memory shrinkage.
+ *
+ * @param useShrinker The new UseMemoryShrinker value
+ */
+ public void setUseMemoryShrinker( boolean useShrinker );
+
+ /**
+ * Whether the memory cache should perform background memory shrinkage.
+ *
+ * @return The UseMemoryShrinker value
+ */
+ public boolean getUseMemoryShrinker();
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space.
+ *
+ * @param seconds The new MaxMemoryIdleTimeSeconds value
+ */
+ public void setMaxMemoryIdleTimeSeconds( long seconds );
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space.
+ *
+ * @return The MaxMemoryIdleTimeSeconds value
+ */
+ public long getMaxMemoryIdleTimeSeconds();
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space. This sets the shrinker interval.
+ *
+ * @param seconds The new ShrinkerIntervalSeconds value
+ */
+ public void setShrinkerIntervalSeconds( long seconds );
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space. This gets the shrinker interval.
+ *
+ * @return The ShrinkerIntervalSeconds value
+ */
+ public long getShrinkerIntervalSeconds();
+
+
// soultion to interface cloning
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @return
+ */
public ICompositeCacheAttributes copy();
}
1.3 +3 -2
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/ElementAttributes.java
Index: ElementAttributes.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/ElementAttributes.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElementAttributes.java 18 Feb 2002 17:14:24 -0000 1.2
+++ ElementAttributes.java 18 Feb 2002 18:17:20 -0000 1.3
@@ -109,12 +109,12 @@
/**
* Max life seconds
*/
- public long mls = 0;
+ public long mls = -1;
/**
* Description of the Field
*/
- public long idle = 0;
+ public long idle = -1;
/**
* The byte size of teh field. Must be manually set.
@@ -137,6 +137,7 @@
public ElementAttributes()
{
this.createTime = System.currentTimeMillis();
+ this.lastAccessTime = this.createTime;
}
1.6 +89 -3
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/CompositeCacheAttributes.java
Index: CompositeCacheAttributes.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/CompositeCacheAttributes.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CompositeCacheAttributes.java 16 Feb 2002 02:37:22 -0000 1.5
+++ CompositeCacheAttributes.java 18 Feb 2002 18:17:20 -0000 1.6
@@ -17,14 +17,27 @@
private boolean useRemote = true;
private boolean useDisk = true;
+ private boolean useMemoryShrinker = false;
+
private int maxObjs = 100;
+ /**
+ * maxMemoryIdleTimeSeconds
+ */
+ protected long maxMemoryIdleTimeSeconds = 60 * 120; // 2 hours
+ /**
+ * shrinkerIntervalSeconds
+ */
+ protected long shrinkerIntervalSeconds = 30;
+
private String cacheName;
private String memoryCacheName;
- /** Constructor for the CompositeCacheAttributes object */
+ /**
+ * Constructor for the CompositeCacheAttributes object
+ */
public CompositeCacheAttributes()
{
// set this as the default so the configuration is a bit simpler
@@ -164,7 +177,76 @@
}
- /** Description of the Method */
+ /**
+ * Whether the memory cache should perform background memory shrinkage.
+ *
+ * @param useShrinker The new UseMemoryShrinker value
+ */
+ public void setUseMemoryShrinker( boolean useShrinker )
+ {
+ this.useMemoryShrinker = useShrinker;
+ }
+
+ /**
+ * Whether the memory cache should perform background memory shrinkage.
+ *
+ * @return The UseMemoryShrinker value
+ */
+ public boolean getUseMemoryShrinker()
+ {
+ return this.useMemoryShrinker;
+ }
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space.
+ *
+ * @param seconds The new MaxMemoryIdleTimeSeconds value
+ */
+ public void setMaxMemoryIdleTimeSeconds( long seconds )
+ {
+ this.maxMemoryIdleTimeSeconds = seconds;
+ }
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space.
+ *
+ * @return The MaxMemoryIdleTimeSeconds value
+ */
+ public long getMaxMemoryIdleTimeSeconds()
+ {
+ return this.maxMemoryIdleTimeSeconds;
+ }
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space. This sets the shrinker interval.
+ *
+ * @param seconds The new ShrinkerIntervalSeconds value
+ */
+ public void setShrinkerIntervalSeconds( long seconds )
+ {
+ this.shrinkerIntervalSeconds = seconds;
+ }
+
+ /**
+ * If UseMemoryShrinker is true the memory cache should auto-expire elements
+ * to reclaim space. This gets the shrinker interval.
+ *
+ * @return The ShrinkerIntervalSeconds value
+ */
+ public long getShrinkerIntervalSeconds()
+ {
+ return this.shrinkerIntervalSeconds;
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ * @return
+ */
public ICompositeCacheAttributes copy()
{
try
@@ -181,7 +263,11 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @return
+ */
public String toString()
{
StringBuffer dump = new StringBuffer();
1.18 +2 -3
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java
Index: Cache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Cache.java 18 Feb 2002 17:14:25 -0000 1.17
+++ Cache.java 18 Feb 2002 18:17:20 -0000 1.18
@@ -631,9 +631,8 @@
try
{
- // Cache item found in memory.
- // The existing logic simply returns null if a cache item is found to
be expired.
- // Don't we also want to remove it from the cache ?
+ // Cache item found in memory. See if it has expired.
+ // If shrinking is on this will be a second level of protection
if ( !ce.getElementAttributes().getIsEternal() && ( (
System.currentTimeMillis() - ce.getElementAttributes().getCreateTime() ) > (
ce.getElementAttributes().getMaxLifeSeconds() * 1000 ) ) )
{
if ( log.isInfoEnabled() )
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>