Until now, we have been dealing primarily with putting, getting, and updating objects in a BackingMap. We can also remove objects in a BackingMap with the ObjectMap remove(Object key)
and removeAll(Collection keys)
methods. Removing an object with the remove(Object key)
method behaves like a remove method on a java.util.Map
in that the object removed from the map is returned from the method. This method obeys the copy mode specified on the BackingMap. The removeAll(Collection keys)
method uses the void return value, and does not return the list of objects removed from a BackingMap.
Removing objects from a BackingMap can also be done by setting a time-to-live on each object. The time-to-live value tells the BackingMap to remove any object older than T seconds, or any object that has not been used in T seconds. We can set the time-to-live value programmatically or in the XML configuration file:
BackingMap bm = grid.defineMap("payments"); bm.setTimeToLive(60 * 60 * 24); bm...