<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">No need, Marcus had it :)<div><br></div><div>I'd do something like</div><div><br></div><div>cacheFactory.usingContext()</div><div> .colocateOn(groupName)</div><div> .getCache() (*)</div><div>(*) assuming the ability to get a cache is</div><div> </div><div>Or is the collocation business something that must be done at the cache level temporarily / for a single operation (thus hosted on the cache interface)?</div><div><br></div><div><br><div><div>On 12 avr. 2010, at 15:30, Vladimir Blagojevic wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Why don't we ping Emmanuel for an advice. He's done similar API design in Hibernate IIRC.<br><div><div>On 2010-04-12, at 8:58 AM, Mircea Markus wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 12 Apr 2010, at 15:36, Manik Surtani wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Re: subject (see <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. 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). 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. 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. 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. </div><div>* Breaks up the call to a put(K, G) and a getAtomicMap(G).put(K, V). 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 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. 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.) Perhaps this could be in an additional sub-interface interface? GroupedCache? Or is this degree of method overloading not too confusing?</div></div></blockquote>what about using an Flag-like api?</div><div>cache.inGroup("groupName").put(...).</div><div>or an "parametrized" flag:</div><div>cache.withFlag(Flags.getColocateFlag("grouName").put(...)</div><div>as long as we can create "parametrized" flags as bellow, I like the second approach</div><div><br></div><div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><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></div>_______________________________________________<br>infinispan-dev mailing list<br><a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a></blockquote></div><br></div>_______________________________________________<br>infinispan-dev mailing list<br><a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a></blockquote></div><br></div>_______________________________________________<br>infinispan-dev mailing list<br><a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/infinispan-dev</blockquote></div><br></div></body></html>