<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 5, 2017 at 9:56 AM, Radim Vansa <span dir="ltr">&lt;<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 04/04/2017 06:40 PM, William Burns wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Apr 4, 2017 at 11:45 AM Katia Aresti &lt;<a href="mailto:karesti@redhat.com">karesti@redhat.com</a><br>
</span><span class="gmail-">&gt; &lt;mailto:<a href="mailto:karesti@redhat.com">karesti@redhat.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi all,<br>
&gt;<br>
&gt;     As you probably know, Will and I are working on the vert-x<br>
&gt;     infinispan integration [1], where the primary goal is to make<br>
&gt;     infinispan the default cluster management of vert-x. (yeah!)<br>
&gt;     Vert-x needs support for an Async Multimap. Today&#39;s implementation<br>
&gt;     is a wrapper on a normal Cache where only Cache Key&#39;s are used to<br>
&gt;     implement the multi map [2].<br>
&gt;     This is not very efficient, so after trying some other alternative<br>
&gt;     implementations [3] that don&#39;t fully work (injection not working),<br>
&gt;     Will and I have come to the conclusion that it might be a good<br>
&gt;     idea to start having our own native CacheMultimap. This first<br>
&gt;     multimap won&#39;t support duplicate values on key&#39;s.<br>
&gt;<br>
&gt;     As a quick start, the smallest multimap we need should implement<br>
&gt;     the following interface :<br>
&gt;<br>
&gt; I agree that having a very slim API to start should be better since we<br>
&gt; know how much trouble we get into implementing a very large API like<br>
&gt; ConcurrentMap :)<br>
&gt;<br>
&gt;     public interface CacheMultimap&lt;K,V&gt; {<br>
&gt;<br>
<br>
</span>I don&#39;t see anything async in this interface. If that&#39;s async, provide<br>
CompletableFuture return values.<br>
I am also considering if we want any fire &amp; forget variants for these<br>
operations, but since we have to do retries to achieve consistency (and<br>
therefore we need some messages from owners to originator), I wouldn&#39;t<br>
include them.<br></blockquote><div><br></div><div>Today&#39;s vert-x API calls the <span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">vertx</span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">.</span><span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">executeBlocking(future =&gt; cache...)</span></div><div><br></div><div>I considered the option of CompletableFuture, but for simplicity I suggested the basic method.</div><div>Today&#39;s CacheAPI makes a difference between &quot;put&quot; and &quot;putAsync&quot;. Would you call the interface CacheMultimapAsync or CacheMultimap with addAsyc method ?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt;         V put(K key,V value);<br>
<span class="gmail-">&gt;<br>
&gt; This should probably return a boolean or Void. I am leaning towards<br>
&gt; the first, but I am open either way.<br>
<br>
</span>I would rather call this &quot;add&quot;, as vert-x does. CompletableFuture as<br>
return type here will allow to easily register the handler</blockquote><div><br></div><div>-1 I prefer keeping &quot;put&quot; name because it is still a Map and makes more sense to me considering the actual Cache API too. The return type V was a transcription mistake, it should be void for me, as Will pointed out.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt;         Collection&lt;V&gt; get(K key);<br>
&gt;<br>
&gt;         boolean remove(K key,V value);<br>
<span class="gmail-">&gt;<br>
&gt; We probably want a `boolean remove(K key)` method as well that removes<br>
&gt; all values mapped to the given key.<br>
<br>
</span>What about &quot;reset(key)&quot;? </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="gmail-"><br>
&gt;     }<br>
&gt;<br>
&gt;     CacheMultimapImpl will be a wrapper on a normal Cache, similar to [3].<br>
&gt;<br>
&gt;     We could add a new method in EmbeddedCacheManager.java<br>
&gt;<br>
&gt;     &lt;K, V&gt; CacheMultimap&lt;K, V&gt; getCacheMultimap(String cacheName,<br>
&gt;     boolean createIfAbsent);<br>
&gt;<br>
&gt;<br>
&gt; I was thinking maybe this would exist in a separate module (outside of<br>
&gt; core)? or class that wraps (similar to DistributedExecutor) instead.<br>
&gt; My worry is about transactions, since the entry point to that is<br>
&gt; through Cache interface. The other option is we could add a `getCache`<br>
&gt; method on the `CacheMultiMap`.<br>
<br>
</span>+1 Since the names of multimaps and maps will clash, we shouldn&#39;t hide<br>
that the underlying implementation is a Cache, so I&#39;d suggest something like<br>
<br>
static &lt;K, V&gt; CacheMultimap&lt;K, V&gt; CacheMultimapFactory.get(<wbr>Cache&lt;K,<br>
Object&gt; c) { ... }<br>
<span class="gmail-"><br>
&gt;<br>
&gt;<br>
&gt;     Implementation will create a cache as always and return a new<br>
&gt;     CacheMultimapImpl(cache).<br>
&gt;<br>
&gt;     What do you think ? Please fell free to suggest any other<br>
&gt;     alternative or idea.<br>
&gt;<br>
&gt;     Cheers<br>
&gt;<br>
&gt;     Katia<br>
&gt;<br>
&gt;     [1] <a href="https://github.com/vert-x3/vertx-infinispan" rel="noreferrer" target="_blank">https://github.com/vert-x3/<wbr>vertx-infinispan</a><br>
&gt;<br>
&gt;     [2]<br>
&gt;     <a href="https://github.com/vert-x3/vertx-infinispan/blob/master/src/main/java/io/vertx/ext/cluster/infinispan/impl/InfinispanAsyncMultiMap.java" rel="noreferrer" target="_blank">https://github.com/vert-x3/<wbr>vertx-infinispan/blob/master/<wbr>src/main/java/io/vertx/ext/<wbr>cluster/infinispan/impl/<wbr>InfinispanAsyncMultiMap.java</a><br>
&gt;<br>
&gt;     [3] <a href="https://gist.github.com/karesti/194bb998856d4a2828d83754130ed79c" rel="noreferrer" target="_blank">https://gist.github.com/<wbr>karesti/<wbr>194bb998856d4a2828d83754130ed7<wbr>9c</a><br>
&gt;     ______________________________<wbr>_________________<br>
&gt;     infinispan-dev mailing list<br>
</span>&gt;     <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.<wbr>jboss.org</a>&gt;<br>
&gt;     <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a><br>
<span class="gmail-im gmail-HOEnZb">&gt;<br>
&gt;<br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a><br>
<br>
<br>
</span><span class="gmail-HOEnZb"><font color="#888888">--<br>
Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt;<br>
JBoss Performance Team<br>
</font></span><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a><br>
</div></div></blockquote></div><br></div></div>