We are planning to use some caching mechanism in our application, and chosen Java Caching System(JCS) after performing comparison study among many other caching solutions. Every thing is fine when I use external configuration (cache.ccf) to define cache regions and its properties( like maxlife, ideltime, etc).
But the requirement is changed to have dynamic cache regions, that is we would need to define cache regions and its properties at run time. I am not able to find more details or samples regarding this operation. I successfully created cache regions at run time ( using below method signature).
ICompositeCacheAttributes cattr=..
IElementAttributes attr = new ElementAttributes();
attr.setIsEternal(false);
attr.setMaxLifeSeconds( maxLife );
defineRegion(name, cattr,attr);
But the problem is, IElmentAttributes does not sets to the cache. I did research on source of JCS and found attr
is never set. It is non used argument!! bit strange
After some more googling, I found below options to set the attributes manually, but still did not work
IElementAttributes attr = new ElementAttributes();
attr.setIsEternal(false);
attr.setMaxLifeSeconds( maxLife );
jcs.setDefaultElementAttributes(attr);
All I want is to set maxLifeSeconds for created regions.
I found way through for my problem, we need to set attributes when you put the data in to cache. See the implementation for somebody who is interested,
JCS jcs = JCS.getInstance("REGION");
IElementAttributes attr = new ElementAttributes();
attr.setIsEternal(false);
attr.setMaxLifeSeconds( maxLife );
jcs.put("Key",data, attr);