I know that you can configure cache attributes for each element (object)
you store in the cache programmatically.

There's an example of programmatic configuration here:
http://jakarta.apache.org/jcs/ElementAttributes.html

I don't know if attributes can be changed once configured however.
Personally, we aren't configuring elements programmatically, we just let
them inherit the region settings, and all servers are deployed with the
same region settings.

You basically want to set IsEternal=true for all your cached elements
when your DB goes offline.

Say in the worst case you can't reconfigure settings, as an alternative
you could...
Pre-configure (in the .ccf file) a new region called "DBOfflineRegion"
or something with IsEternal=true, but otherwise with settings similar to
those you use when your DB is online.
When your code detects that the DB is down, it iterates through all
cached items in your normal region, and copies them into the
DBOfflineRegion. It could remove them from the normal region as it
copies them, to save memory I guess.
Subsequently while the DB is down, your code is programmed to fetch data
from the DBOfflineRegion, as long as the DB remains down. When the DB
comes back online your code reverts back to using the normal region, and
clears the DBOfflineRegion.

Of course none of this would be necessary if you can just change
IsEternal or MaxLifeSeconds settings on-the-fly. You might be able to
effectively do that by retrieving everything from your normal region and
re-putting objects back into the same region with different attributes.
In general re-configuring everything in a distributed cache might
complicate things. Someone else could advise if it's supported.


On Wed, 2008-05-21 at 10:04 -0700, trekmbikes wrote:

> Hello,
> 
> My project needs to add flexibility such that when our real data source goes
> offline, JCS continues to return the cached items until some point later
> when we bring the DB back online. We will handle the condition gracefully
> when a non-cached item is requested during the downtime. The idea is to keep
> the content flowing for those users who are already logged in and are only
> requesting cached items.
> 
> The items returned by the cache are normally time-bound (in fact, they are
> user session objects) - so we normally use the cache parameter
> "MaxLifeSeconds" so they expire automatically. Is there a way to disable the
> MaxLifeSeconds parameter and re-enable it later?
> 
> If not, I'm also considering storing wrapper objects for everything in the
> cache, that contain both the real object I'm storing and an insertion millis
> value. We would perform the timeout logic ourselves - and remove the
> MaxLifeSeconds completely. Has anyone tried this?

Reply via email to