You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by Datta Mane <da...@gmail.com> on 2012/01/11 08:34:29 UTC

Event handling related Question. Memory Shringker thread

This is  scenario I am stuck with

EPG (Electronic programming guide): has data  which is frequently updated

MY WEB APP:  On load calls the EPG Services and load data into JCS cache
After few minutes Say 15 minutes I have to make a call to EPG Service and
get the new Data
*jcs.region.metadataCache.cacheattributes.UseMemoryShrinker=true*
and
jcs.region.metadataCache.elementattributes.IdleTime=120

Based on this documentation
http://commons.apache.org/jcs/apidocs/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.html

My understanding is  when Memory Shrinker Property is set to true and Idle
Time is exceeded
Shrinked thread will remove the Cached Object from memory and invoke
 Eventhandlers handleElementEvent(IElementEvent iElementEvent)

And it does invoke the handleElementEvent(IElementEvent iElementEvent)
So  I put the code below  in handleElementEvent  to load Data
/******************/
                case
IElementEventConstants.ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND:
                    event = (ElementEvent) iElementEvent;
                    element = (CacheElement) event.getSource();
                    //TODO
                loadDataFromEPG("TVGUIDE"); // reload data into Cache
                    break;

/******************/

The issue is Shrinker Thread Calls  handleElementEvent  only for the first
time when the cached exceed Idle time
After reloading When the newly Cached Object exceeds the
ideltime handleElementEvent
is not invoked.

Is this a BUG ?  or Am I doing any thing wrong
How can I resolve this JCS API.

Other option I have  is to use  Quartz Job  to refresh data in Local JCS
cache at specified interval which I want to avoid.

Thanks
Datta