Expresso 5-6

com.jcorporate.expresso.core.cache
Class CacheCleaner

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.jcorporate.expresso.core.registry.ExpressoThread
          extended bycom.jcorporate.expresso.core.cache.CacheCleaner
All Implemented Interfaces:
Runnable

public class CacheCleaner
extends com.jcorporate.expresso.core.registry.ExpressoThread

This thread is initialized by CacheManager and slowly iterates through the Caches clearing out expired items. It often is given a lower thread priority so it doesn't take away from the app server during high use times.

By using this thread, we save significant memory by removing expired items before they are accessed again.

Typical Usage:

 CacheCleaner cacheCleaner = new CacheCleaner();
 cacheCleaner.registerCacheSystem(defaultContextCacheSystem);
 cacheCleaner.start();
 .....
 .....
 //To shut down.  May take a while.
 cacheCleaner.interrupt();
 cacheCleaner.join();
 

Author:
Michael Rimov

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected CacheCleaner()
           
 
Method Summary
 void interrupt()
           
 void registerCacheSystem(CacheSystem newCache)
          Register a cache system for iteration.
 void run()
          The cache cleaner run method iterates through all the cache systems installed in the system and forces the removal of any items that have expired.
 
Methods inherited from class com.jcorporate.expresso.core.registry.ExpressoThread
getThreadContext
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheCleaner

protected CacheCleaner()
Method Detail

registerCacheSystem

public void registerCacheSystem(CacheSystem newCache)
Register a cache system for iteration. During a pass of the cache, the CacheCleaner will iterate all registered CacheSystems

Parameters:
newCache - the CacheSystem instance to be cleaning.

run

public void run()
The cache cleaner run method iterates through all the cache systems installed in the system and forces the removal of any items that have expired. It automatically runs every 30 seconds.


interrupt

public void interrupt()

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.