Many things at a time

We have previously seen that Hazelcast provides us with a generic key-value map. However, this capability is popularly used to create a key/list-of-values map. While there is nothing stopping us from defining these ourselves using the standard Java generics, we will have to manually handle the initialization of each key entry. Hazelcast has luckily gone out of its way to make our lives easier by handling this case for us by using the specialized MultiMap collection.

Let's have a look at the following example:

public class MultiMapExample { public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); Map<String, List<String>> manualCities = hz.getMap("manualCities"); List<String> gbCities ...

Get Getting Started with Hazelcast - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.