org.apache.jcs.engine.memory.shrinking
Class ShrinkerThread

java.lang.Object
  extended by org.apache.jcs.engine.memory.shrinking.ShrinkerThread
All Implemented Interfaces:
java.lang.Runnable

public class ShrinkerThread
extends java.lang.Object
implements java.lang.Runnable

A background memory shrinker. Memory problems and concurrent modification exception caused by acting directly on an iterator of the underlying memory cache should have been solved.

Version:
$Id: ShrinkerThread.java 689591 2008-08-27 19:44:33Z asmuts $

Constructor Summary
ShrinkerThread(MemoryCache cache)
          Constructor for the ShrinkerThread object.
 
Method Summary
 void run()
          Main processing method for the ShrinkerThread object
protected  void shrink()
          This method is called when the thread wakes up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShrinkerThread

public ShrinkerThread(MemoryCache cache)
Constructor for the ShrinkerThread object.

Parameters:
cache - The MemoryCache which the new shrinker should watch.
Method Detail

run

public void run()
Main processing method for the ShrinkerThread object

Specified by:
run in interface java.lang.Runnable

shrink

protected void shrink()
This method is called when the thread wakes up. Frist the method obtains an array of keys for the cache region. It iterates through the keys and tries to get the item from the cache without affecting the last access or position of the item. The item is checked for expiration, the expiration check has 3 parts:
  1. Has the cacheattributes.MaxMemoryIdleTimeSeconds defined for the region been exceeded? If so, the item should be move to disk.
  2. Has the item exceeded MaxLifeSeconds defined in the element attributes? If so, remove it.
  3. Has the item exceeded IdleTime defined in the element atributes? If so, remove it. If there are event listeners registered for the cache element, they will be called.



Copyright © 2002-2009 Apache Software Foundation. All Rights Reserved.