On Tue, Apr 4, 2017 at 11:45 AM Katia Aresti <karesti@redhat.com> wrote:
Hi all,

As you probably know, Will and I are working on the vert-x infinispan integration [1], where the primary goal is to make infinispan the default cluster management of vert-x. (yeah!)
Vert-x needs support for an Async Multimap. Today's implementation is a wrapper on a normal Cache where only Cache Key's are used to implement the multi map [2].
This is not very efficient, so after trying some other alternative implementations [3] that don't fully work (injection not working), Will and I have come to the conclusion that it might be a good idea to start having our own native CacheMultimap. This first multimap won't support duplicate values on key's.

As a quick start, the smallest multimap we need should implement the following interface :
 
I agree that having a very slim API to start should be better since we know how much trouble we get into implementing a very large API like ConcurrentMap :) 
public interface CacheMultimap<K, V> {
V put(K key, V value);
This should probably return a boolean or Void. I am leaning towards the first, but I am open either way.

Collection<V> get(K key);

boolean remove(K key, V value);
We probably want a `boolean remove(K key)` method as well that removes all values mapped to the given key.
}
CacheMultimapImpl will be a wrapper on a normal Cache, similar to [3].

We could add a new method in EmbeddedCacheManager.java

<K, VCacheMultimap<K, V> getCacheMultimap(String cacheName, boolean createIfAbsent);

I was thinking maybe this would exist in a separate module (outside of core)? or class that wraps (similar to DistributedExecutor) instead. My worry is about transactions, since the entry point to that is through Cache interface. The other option is we could add a `getCache` method on the `CacheMultiMap`.
 


Implementation will create a cache as always and return a new CacheMultimapImpl(cache). 

_______________________________________________
infinispan-dev mailing list
infinispan-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev