I'm half-asleep and this is half-baked, but want to write it down before I sleep and forget about it :) Luckily I have the power to delete posts, so if I wake up, read this and am embarassed, well.... poof!
Use integers as keys. In CachedSetImpl add a field private Map<Object, Integer> keyLookup = new HashMap(); In add(), after you call putObject(), call getObject() to get back the POJO. (This is probably only necessary if the POJO is a Collection, otherwise you already have the POJO.) Anyway, put the POJO and its key in the keyLookup map. Tricky thing is the keyLookup map can't be trusted, as it won't be updated if the set is changed due to replication. It's just an optimization. When you need to find a value (e.g. in contains()), you first check the map. If you find a key, go look up the pojo, confirm equals(). If equals() == true, done. If equals() == false, remove the now invalid entry from the map. Unfortunately, if you don't find a key or it's invalid, you have to scan through the child nodes to confirm you really don't have it :( If you find you do have it, add it to the map. So all this only helps in the case where you do have something. Which is not the normal case :( If there were a way the CachedSetImpl could know if members have been added or removed due to replication, then the map could be kept up-to-date and the scan avoided. Or if there were a fast way to check whether the map is up-to-date.... Anyway, off to bed.. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3921634#3921634 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3921634 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
