Well, I hope your hash function is well thought through :-) otherwise using hashmap for caching might be a mess....
On Wed, Jun 17, 2009 at 4:30 PM, Renè Glanzer<[email protected]> wrote: > I was searching for a very lighweight cache systems with not much overhead > for my purposes. The LRUMap just matched > perfectly except the little iterator problem. > > > 2009/6/17 James Carman <[email protected]> > >> Or, ehcache or oscache or something like that? >> >> On Wed, Jun 17, 2009 at 10:17 AM, Leon >> Rosenberg<[email protected]> wrote: >> > why don't you just use softreference + expiration timestamp and save >> > all the trouble? >> > Leon >> > >> > On Wed, Jun 17, 2009 at 4:07 PM, Renè Glanzer<[email protected]> >> wrote: >> >> Hi, >> >> >> >> it's me again with an update. >> >> the LRUMap.mapIterator() still produces the >> >> ConcurrentModificationException when a call to MapIterator.remove() >> >> occurs. >> >> >> >> Maybe this info helps >> >> René >> >> >> >> >> >> 2009/6/17 Renè Glanzer <[email protected]>: >> >>> Hi Jörg, >> >>> >> >>> it's me again. With a smile on my face :-) >> >>> >> >>> I changed my code according to your hint. >> >>> Now i don't use the keySet but the entrySet. With only to adopt the >> rest of >> >>> the method to the entrySet and still >> >>> calling the remove() method of the iterator in my tests no >> >>> ConcurrentModificationException occured!! >> >>> >> >>> Additionally now I'm using the LURMap.mapIterator() which also performs >> well >> >>> and according to the docu should be prefered over the entrySet or >> keySet. >> >>> >> >>> Now the new an well working code looks like this: >> >>> >> >>> public void removeAllExpiredItems() >> >>> { >> >>> synchronized(this.store) >> >>> { >> >>> MapIterator it=this.store.mapIterator(); //Here I'm using the new >> >>> MapIterator >> >>> while(it.hasNext()) >> >>> { >> >>> m_catLog.debug("Reading object"); >> >>> Object key=it.next(); >> >>> Item currentItem=(Item)it.getValue(); >> >>> if(currentItem.birth==0) >> >>> { >> >>> m_catLog.debug("0 birth found for key "+key+" calling >> >>> Iterator.remove"); >> >>> it.remove(); >> >>> } >> >>> } >> >>> this.setLastCleanDate(new Date()); >> >>> } >> >>> } >> >>> >> >>> Thousand Thanks for your help Jörg >> >>> this fixed my Problem and maybe also fixes the problems from the other >> >>> people who suffered the same problem. >> >>> Furthermore I'm pleased to see that the JIRA issue COLLECTION-330 is >> >>> handling the problem with the keySet call. >> >>> >> >>> 2009/6/17 Jörg Schaible <[email protected]> >> >>>> >> >>>> Renè Glanzer wrote at Mittwoch, 17. Juni 2009 11:48: >> >>>> >> >>>> > Hi Jörg, >> >>>> > >> >>>> > that are great news, I'll give it a try. >> >>>> > And of course I'll report my experience. >> >>>> >> >>>> That would be fine. Actually I opened an own JIRA issue for this now >> >>>> (COLLECTION-330), COLLECTION-3 was simply too vague and had a too long >> >>>> history of different symptoms. >> >>>> >> >>>> - Jörg >> >>>> >> >>>> >> >>>> --------------------------------------------------------------------- >> >>>> To unsubscribe, e-mail: [email protected] >> >>>> For additional commands, e-mail: [email protected] >> >>>> >> >>> >> >>> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [email protected] >> >> For additional commands, e-mail: [email protected] >> >> >> >> >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: [email protected] >> > For additional commands, e-mail: [email protected] >> > >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
