<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><meta charset="utf-8"><div>Re: subject (see&nbsp;<a href="https://jira.jboss.org/jira/browse/ISPN-359">https://jira.jboss.org/jira/browse/ISPN-359</a>), there are a couple of approaches that could be taken:</div><div><br></div><div>1. &nbsp;Don't use key.hashcode() as the seed in determining to which nodes an entry is mapped, but instead on a well-known method or annotated method (e.g., int getGroupID() or a method annotated with @GroupId). &nbsp;The way I see it, this approach has:</div><div><br></div><div>+ Will work, no additional overheads of AtomicMaps</div><div>- Cost (reflection)</div><div>- Intrusive (what if users have no control over the key class, e.g., String keys?)</div><div><br></div><div>2. &nbsp;Additional API methods on the cache - cache.put(K, V, G), cache.putAll(Map, G), etc.</div><div><br></div><div>+ Non-intrusive</div><div>- Overhead of AtomicMaps + additional entries for mappings</div><div>+ or - (depending on how you look at it) all keys in the group will be locked together, etc, a side-effect of using AtomicMaps</div><div><br></div><div>My pref is for approach #2. &nbsp;In terms of implementation, here is what I have in mind:</div><div><br></div><div>* A GroupingInterceptor that intercepts the call early on if the call is a put(K, V, G) or something similar. &nbsp;</div><div>* Breaks up the call to a put(K, G) and a getAtomicMap(G).put(K, V). &nbsp;Wrapped in a tx to ensure atomicity.</div><div>* get(K), etc intercepted as well, replaced with getAtomicMap(get(K)).get(K)</div><div>* remove(K), etc intercepted with&nbsp;getAtomicMap(get(K)).remove(K)</div><div><br></div><div>One of the issues with the API approach is that it heavily pollutes the Cache API. &nbsp;It will double the number of put() methods on Cache (currently 18 variants of put, including ones that take in lifespans and maxIdles, async versions that return futures, etc.) &nbsp;Perhaps this could be in an additional sub-interface interface? &nbsp;GroupedCache? &nbsp;Or is this degree of method overloading not too confusing?</div><div><br></div><div>Cheers,</div><div>
<span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Manik Surtani</div><div><a href="mailto:manik@jboss.org">manik@jboss.org</a></div><div>Lead, Infinispan</div><div>Lead, JBoss Cache</div><div><a href="http://www.infinispan.org">http://www.infinispan.org</a></div><div><a href="http://www.jbosscache.org">http://www.jbosscache.org</a></div><div><br></div></div></span><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br></body></html>