I have a use case for which I need to implement a distributed set, so I was thinking just to use a distributed Cache in which each entry would map to a set entry .
The problem is that I should be able to extract an entry from the set without using its key, let's say the getFirst (but it is not required to maintain the entries ordered).
The first solution would be something like this:
But the documentation states clearly that the methods entrySet(), keySet() and values() should not be used in production.
Is there any efficient or suggested alternative to implement it ? Using a L1 cache ?
If your set is small enough then you should use a replicated cache for which the keySet/entrySet methods should work.
Alternativelly you can use a Map/Reduce task in order to do just that: https://docs.jboss.org/author/display/ISPN/Map+Reduce+framework