Hazelcast Listener for removing hierarchical dependent data?

Viewed 156

Trying to understand more into best practices when dealing with incomplete hierarchical cached data.

Example: I have two caches

  1. Per Resource cache {"foo": "bar", "parent", "${Object}"}
  2. Per parent. [{"foo": "bar", "parent", "${Object}"}, {"foo": "buz", "parent", "${Object}"}]

When a resource is deleted I want to ensure that it is removed from both of the caches AND all of its decedents are also removed.

Originally it appeared like an EventListener could resolve this, however this can quickly cascade in event types if we have a root item (like your C:\ drive) is deleted and it has millions of children. This would register an event for each child item.

Another approach appears to be using topics but I am uncertain if that would give similar performance to EventListeners.

Are there any other routes or ways to listen to cache events only some of the time?

1 Answers

Listeners work fire&forget so you might end up with incomplete deleted records in cases like network disruption.

To me, safest approach would be to place related entries of different maps on the same member by using PartitionAware interface and use an executor to remove a record and it's childs/parents. The Order/Customer example in the link should reflect your use case.

Related