Book Image

Getting Started with Hazelcast

By : Matthew Johns
Book Image

Getting Started with Hazelcast

By: Matthew Johns

Overview of this book

Table of Contents (18 chapters)
Getting Started with Hazelcast
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The sound of our own data


Being notified as our data changes can be rather useful, so we can make an application-level decision on whether that change is important or not. The first interface we are going to look at is EntryListener. This class will notify us when changes are made to the entries stored in a map collection. If we take a look at the interface, we can see four event types that we will be notified about.

public interface EntryListener<K, V> extends EventListener {
  void entryAdded(EntryEvent<K, V> event);
  void entryRemoved(EntryEvent<K, V> event);
  void entryUpdated(EntryEvent<K, V> event);
  void entryEvicted(EntryEvent<K, V> event);
}

Hopefully, the first three are pretty self-explanatory; however, the last is a little less clear and in fact, one of the most useful. The entryEvicted method is invoked when an entry is removed from a map non-programmatically (that is, Hazelcast has done it all by itself). This instance will occur in one of two...