TimestampsRegionCache extends LocalRegionCache implements RegionCache { @Override public boolean put(Object key, Object value, long txTimestamp, Object version) { boolean succeed = super.put(key, value, txTimestamp, version); if (succeed) { maybeNotifyTopic(key, value, version); } return succeed; } TimestampsRegionCache(final String name, final HazelcastInstance hazelcastInstance); @Override boolean put(Object key, Object value, long txTimestamp, Object version); @Override void clear();  }
@Test public void shouldUseClusterTimestampFromInvalidationmessageInsteadOfSystemTime() { long firstTimestamp = 1; long secondTimestamp = 2; long publishTime = 3; long clusterTime = 4; when(cluster.getClusterTime()).thenReturn(firstTimestamp, secondTimestamp); assertThat(target.put("QuerySpace", firstTimestamp, firstTimestamp, null), is(true)); assertThat("primed value should be in the cache", (Long)target.get("QuerySpace", firstTimestamp), is(firstTimestamp)); Message<Object> message = new Message<Object>("topicName", new Timestamp("QuerySpace", secondTimestamp), publishTime, member); listener.onMessage(message); assertThat("key should be visible and have value specified in timestamp message, with current cluster time.", (Long)target.get("QuerySpace", clusterTime), is(secondTimestamp)); }