We have implemented near cache, I have written a hotrod client program which first puts data in the cache, and then it retrieves it in a loop, with thread sleep of 1 second. First read hit is on the server, and then subsequent reads are from the near cache. Meanwhile, suppose, if the cluster crashes, or assume all the nodes on which the distributed cache was stored, they all crashed, what will I get when I do cache.get(key). Will the near cache be invalidated at all? What happens if servers are shut down appropriately, not abruptly??
This is already explained in the documentation. Notifications to a near cache come from one of the nodes in the cluster. If that node goes down (regardless of abrupt or appropriately), the client detects that, clears the near cache and re-registers the near cache in another node in the cluster.