JBoss Community

Re: Using ExpirationAlgorithm in EvictionConfig not working in JBoss 5.1

created by Thomas Hofmann in JBoss Cache - View the full discussion

Sorry, missed some lines in the code. Here is the complete code:

 

CacheManager cacheManager = com.bspartners.util.ServiceLocator.getCacheManager();

Cache expirationCache = cacheManager.getCache("prodb-expiration-cache", true);

 

Node rootNode = expirationCache.getRoot();

Fqn cacheFqn = Fqn.fromString("/OTTO");

Region region = expirationCache.getRegion(cacheFqn, true);

ExpirationAlgorithmConfig expirationAlgorithmConfig = new ExpirationAlgorithmConfig();

expirationAlgorithmConfig.setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);

EvictionRegionConfig erc = new EvictionRegionConfig(cacheFqn, expirationAlgorithmConfig);

region.setEvictionRegionConfig(erc);

EvictionConfig evictionConfig = new EvictionConfig();

List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();

ercs.add(erc);

evictionConfig.setEvictionRegionConfigs(ercs);

evictionConfig.setWakeupInterval(500);

expirationCache.getConfiguration().setEvictionConfig(evictionConfig);

Node cacheNode = rootNode.getChild(cacheFqn);

Long future = new Long(System.currentTimeMillis() + 10000);

Fqn keyFqn = Fqn.fromElements(key);

cacheNode.addChild(keyFqn).put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);

cacheNode.getChild(keyFqn).put("key_1", "value_1");

 

Object value = rootNode.getChild(cacheFqn).getChild(Fqn.fromElements("key_1)).get("key_1");

 

Would be very appreciate for any hint, which will do that stuff work!!

Reply to this message by going to Community

Start a new discussion in JBoss Cache at Community