Class ShrinkerThread<K,V>

java.lang.Object
org.apache.commons.jcs3.engine.memory.shrinking.ShrinkerThread<K,V>
All Implemented Interfaces:
Runnable

public class ShrinkerThread<K,V> extends Object implements 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.
  • Constructor Details

    • ShrinkerThread

      public ShrinkerThread(CompositeCache<K,V> cache)
      Constructor for the ShrinkerThread object.

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

    • run

      public void run()
      Main processing method for the ShrinkerThread object
      Specified by:
      run in interface Runnable
    • shrink

      protected void shrink()
      This method is called when the thread wakes up. First 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 attributes? If so, remove it. If there are event listeners registered for the cache element, they will be called.
      TODO Change element event handling to use the queue, then move the queue to the region and access via the Cache.