Sets, lists, and queues

In the previous examples, we 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 you may be already familiar with—sets and lists.

The primary difference between these two collections is that lists allow for multiple entries and a set does not. So, if we add them to the previous map example, we will 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"); ...

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.