We have seen previously that Hazelcast provides us with a generic key/value map; however, one popular use of this capability would be to create a key/list-of-values map. While there is nothing stopping us from defining these ourselves using 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, through the use of the specialized MultiMap
collection.
Let's have a look at the following example:
Map<String, List<String>> manualCities = hz.getMap("manualCities"); List<String> gbCities = new ArrayList<String>(); manualCities.put("GB", gbCities); gbCities = manualCities.get("GB"); gbCities.add("London"); manualCities.put("GB", gbCities); gbCities = manualCities.get("GB"); gbCities.add("Southampton"); manualCities.put("GB", gbCities); List<String> frCities = new ArrayList<String>(); manualCities.put("FR...