[jboss-user] [JBoss Cache: Core Edition] - How do items get automatically removed from the cache?
eightmd
do-not-reply at jboss.com
Wed Jul 2 14:43:40 EDT 2008
I've just started looking at JBossCache and I was writing some tests to see how it works. I am trying to put nodes into the cache and then see them expire. I have used a region and used n LRU eviction policy. I was thinking that setting TimeToLiveSeconds and/or MaxAgeSeconds would cause the node to be completely removed from the cache. I know that the RegionManager has to wake up so I setWakeUpIntervalSeconds on the EvictionConfiguration to 4 seconds.
| LRUConfiguration lru = new LRUConfiguration();
| lru.setMaxNodes(5000);
| lru.setTimeToLiveSeconds(2);
| lru.setMaxAgeSeconds(2);
|
I did a sleep for 10 seconds and the node was still there.
I then tried doing the following which I found in the user manual.
| Long future = new Long(System.currentTimeMillis() + 2000);
| cache.getRoot().getChild(nodeFqn).put(ExpirationConfiguration.EXPIRATION_KEY, future);
|
| assertTrue(cache.getRoot().hasChild(nodeFqn));
| Thread.sleep(10000);
|
| // after 5 seconds, expiration completes
| assertFalse(cache.getRoot().hasChild(nodeFqn));
|
The node was still there.
Then I tried this:
| ExpirationConfiguration ec = new ExpirationConfiguration();
| ec.setTimeToLiveSeconds(2);
|
| cache.getRoot().getChild(nodeFqn).put(ExpirationConfiguration.EXPIRATION_KEY, ec);
|
| assertTrue(cache.getRoot().hasChild(nodeFqn));
| Thread.sleep(10000);
|
| // after 5 seconds, expiration completes
| Node n1 = cache.getRoot().getChild(nodeFqn);
| assertFalse(cache.getRoot().hasChild(nodeFqn));
|
The node was still there. So if anyone can tell me what I'm missing I would appreciate it. I am expecting to see the node gone from the cache by one of these methods. Thanks for any help you can provide.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162152#4162152
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4162152
More information about the jboss-user
mailing list