In our previous examples, we have looked at key/value storage provided by Hazelcast maps; however, there are a number of other collections that provide keyless groups of objects. Two of these additional types are distributed versions of collections that we are hopefully already familiar with—sets and lists.
As we know, the primary difference between the two is that lists allow for multiple entries and a set does not. So if we add them to our previous map example, we get the following code:
Set<String> cities = hz.getSet("cities"); cities.addAll(captials.values()); cities.add("London"); cities.add("Rome"); cities.add("New York"); List<String> countries = hz.getList("countries"); countries.addAll(captials.keySet()); countries.add("CA"); countries.add("DE"); countries.add("GB"); // duplicate entry
In using our test console again to interact with these new collections, we will have to use different commands as we are now interacting with a set and a list rather...