Clustered invalidation key-value caches are sending only remove commands over the network. When the value of a key is changed or removed on one node a remove command is sent with that key to every other node so they need to get that data from a persistent store (or re-calculate it) next time they need it.
My question is: How it is defined based on the javax.cache.Cache interface? There is put, putIfAbsent, replace, ... functions there.
Using Infinispan-jcache I could not have a behaviour when the same key exists on two different node. I asked the same question on their user forum at https://community.jboss.org/thread/228039 however I think this is a more common question where all JSR-107 implementations are affected.
I checked the draft specification but I could not find anything about Clustering and invalidation there.
The way Infinispan is working is correct. Invalidation means that when a node receives a put/replace/putIfAbsent/remove calls, it will send a message to the other nodes to remove the entry. So, when the entry is stored in cache2, it's removed from cache1. It doesn't verify if the value is the same or not.
JSR-107 does not specify how caches should behave in a cluster. JSR-107 only focuses on local caches. The behaviour of Infinispan caches, even under JCache API, for invalidated, distributed and replicated caches is specific to Infinispan.