use of com.hazelcast.internal.nearcache.impl.NearCachingHook in project hazelcast by hazelcast.
the class TransactionalMapProxy method putIfAbsent.
@Override
public Object putIfAbsent(Object key, Object value) {
checkTransactionState();
checkNotNull(key, "key can't be null");
checkNotNull(value, "value can't be null");
Data keyData = mapServiceContext.toData(key, partitionStrategy);
Data valueData = mapServiceContext.toData(value);
NearCachingHook invalidationHook = newNearCachingHook();
invalidationHook.beforeRemoteCall(key, keyData, value, valueData);
TxnValueWrapper wrapper = txMap.get(keyData);
boolean haveTxnPast = wrapper != null;
if (haveTxnPast) {
if (wrapper.type != Type.REMOVED) {
return wrapper.value;
}
putInternal(keyData, valueData, UNSET, MILLISECONDS, invalidationHook);
txMap.put(keyData, new TxnValueWrapper(value, Type.NEW));
return null;
} else {
Data oldValue = putIfAbsentInternal(keyData, valueData, invalidationHook);
if (oldValue == null) {
txMap.put(keyData, new TxnValueWrapper(value, Type.NEW));
}
return toObjectIfNeeded(oldValue);
}
}
Aggregations