Class ShrinkerThread<K,V>
java.lang.Object
org.apache.commons.jcs3.engine.memory.shrinking.ShrinkerThread<K,V>
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionShrinkerThread
(CompositeCache<K, V> cache) Constructor for the ShrinkerThread object. -
Method Summary
-
Constructor Details
-
ShrinkerThread
Constructor for the ShrinkerThread object.- Parameters:
cache
- The MemoryCache which the new shrinker should watch.
-
-
Method Details
-
run
Main processing method for the ShrinkerThread object -
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:- Has the cacheattributes.MaxMemoryIdleTimeSeconds defined for the region been exceeded? If so, the item should be move to disk.
- Has the item exceeded MaxLifeSeconds defined in the element attributes? If so, remove it.
- 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.
-