0

I want to know if there is a way to let Hazelcast automatically sync the cache with all the updates that an entity receives. here's an example: I want to update an entity that has been stored into a cache and is also used in other caches. I do a get() and retrieve the value, and then perform an update changing some properties. The problem is that Hazelcast does not automatically serialize the item in the cache after every change, but i need to force a put to actually propagate the update to the cache. And i would need to perform a put for every cache that my entity is stored into. Is there someway to let Hazelcast manage those situations automatically?

#Edit

Just to clarify the problem, here i give you an example: imagine i have 2 IMaps: map1 stores objects of Entity A, map2 contains object of entity B, and entity B represents a complex object which in turn contains Entity A. If i want to perform an edit on one of the objects contained in map1 (which will be an instance of Entity A), i will do a map1.get(key) and retreive the object. Then i modify this object in some way and i will persist the changes in map1 by doing a map1.put(key, entityA). The problem rises because in map2, all the entitiesB which contain the jsut modified entityA will not show the update, and i have to manually do a get and a put also in this map.

Bambatrack
  • 51
  • 4

1 Answers1

0

You can use EntryProcessor to update the content of the entity in the map, directly on the server (without having to perform a get() first). That ways a common update code can be used for all the caches and you save on all network and ser/des overheads too.

wildnez
  • 1,078
  • 1
  • 6
  • 10