jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Smuts <asm...@yahoo.com>
Subject Re: JCS question
Date Thu, 06 Jul 2006 17:50:17 GMT
Altough it is not ideal, you can simple have the event
handler put the item back into the cache.

It might be better to handle this programatically. 
You can determine the age of an item by simply
retrieving the CacheElement rather than the item.  

call getCacheElement on the JCS class.  You can get
the create time in the ElementAttributes.  Set the
exipration to eternal or something very long in the
cache.ccf.  If the item is very old, try to fetch
another.  If you can't get it, then return the cached
item and put a refresh request on a queue.  If the
item is kind of stale, then queue up a refresh and
return what you got from the cache.

I do this in several places in my current application.

Aaron

--- Scott Golubock <scottg@ZAAZ.com> wrote:

> i'd like to write some custom code that gets
> executed after an object
> exceeds its max life in the cache, and is ultimately
> responsible for
> deciding whether or not the object actually gets
> removed from cache.
> this code might decide to keep an object in cache
> even after it has
> expired (reset its max life period).
>  
> i know i can register event handlers for various
> timeout events, but
> don't see anything that lets me do anything before
> the object is
> actually removed.
>  
> any thoughts on if this is possible, or how i could
> accomplish it?
>  
> here is more information about my specific use case,
> in case there are
> other ideas:
> i have an application that retrieves data from a
> remote system and
> caches it for a period of time.  the application
> checks the cache first,
> and if the data isn't there (after a timeout for
> example) it will goto
> the remote system.  unfortunately, the remote system
> is flaky and
> frequently unavailable.  so, i'd like to write some
> code that pings the
> remote system before the cache is reset, so that
> cached data can be
> saved longer if the remote system is down.
>  
> another solution may be to configure JCS so that the
> cache never
> expires, and write my own code that runs as a
> background thread and
> manually resets the JCS cache when necessary, ie:
> JCS.getInstance("cacheName").clear();
> but this feels hacky to me for some reason.  it
> seems like i may be able
> to extend or override something in JCS to achieve
> this.
>  
> thanks in advance ...
> scott
>  
>  
>  
>  
>  
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org


Mime
View raw message