-
1. Re: TimedCachedPolicy never removes entries from cache
ramazanyich Jan 15, 2007 5:16 AM (in response to frebe73)Still have exactly the same issue in jboss4.0.4GA (probably JBOSS4.0.5.GA as sources of this part are not changed).
We also have thousands of users.
For a moment only possible solution is to extend TimedCachePolicy class and reiplement run() method. Currently this method only changes current time.
But expired objects can be removed at this time.
public void run() {
super.run();
synchronized (entryMap) {
Iterator iter = entryMap.entrySet().iterator();
List removeentries = new ArrayList();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
TimedEntry value = (TimedEntry) entry.getValue();
if (value.isCurrent(now) == false) {
if(log.isDebugEnabled()){
log.debug("destroying object:"+value);
}
value.destroy();
removeentries.add(entry.getKey());
}
}
for (Object object : removeentries) {
if(log.isDebugEnabled()){
log.debug("removing object from Map:"+object);
}
entryMap.remove(object);
}
}
} -
2. Re: TimedCachedPolicy never removes entries from cache
anil.saldhana Aug 1, 2007 2:51 PM (in response to frebe73)This discussion is wrt
http://jira.jboss.com/jira/browse/JBAS-3986
I am wondering maybe we can flush the cache at a configurable number of access. If the cache is accessed at say the 100th time, do a cache flush. -
3. Re: TimedCachedPolicy never removes entries from cache
starksm64 Aug 1, 2007 7:47 PM (in response to frebe73)Sure, but the impl needs to be updated to use a ConcurrentHashMap so that the flush is not blocking access. You could also look at using the java.util.concurrent.DelayQueue to know exactly when entries have expired and how many have expired.