Search code examples
javacachingreplicationhazelcasthazelcast-imap

Hazelcast update replicated map


Hei,

I'm using Hazelcast ReplicatedMap to store some objects. In order to save the objects in the map I'm using the put method from the ReplicatedMap interface( aka V put(K var1, V var2, long var3, TimeUnit var5); which allows me to clear that entry after some time.

Now if I want to update an object in the map I would use put(idOfOldObject, newObject).

My question is: will this new entry be cleared after the remaining time since the first one was put in the map? To be more explicit here is some pseudocode of what I'm trying to ask:

map.put(1,objectX,10,"seconds"); //as far as i understand this will remove the entry after 10 seconds.
objectX.updateField();
map.put(1,objectX); //will objectX still be removed after 10 seconds now?

Solution

  • The eviction is scheduled by the first put operation. That said, when the second put happens before the scheduled removal is executed, the "new value" will be removed. If that makes sense :)