use of com.hazelcast.internal.nearcache.impl.NearCachingHook in project hazelcast by hazelcast.
the class TransactionalMapProxy method remove.
@Override
public Object remove(Object key) {
checkTransactionState();
checkNotNull(key, "key can't be null");
Data keyData = mapServiceContext.toData(key, partitionStrategy);
NearCachingHook invalidationHook = newNearCachingHook();
invalidationHook.beforeRemoteCall(key, keyData, null, null);
Object valueBeforeTxn = toObjectIfNeeded(removeInternal(keyData, invalidationHook));
TxnValueWrapper wrapper = null;
if (valueBeforeTxn != null || txMap.containsKey(keyData)) {
wrapper = txMap.put(keyData, new TxnValueWrapper(valueBeforeTxn, Type.REMOVED));
}
return wrapper == null ? valueBeforeTxn : checkIfRemoved(wrapper);
}
use of com.hazelcast.internal.nearcache.impl.NearCachingHook in project hazelcast by hazelcast.
the class TransactionalMapProxy method delete.
@Override
public void delete(Object key) {
checkTransactionState();
checkNotNull(key, "key can't be null");
Data keyData = mapServiceContext.toData(key, partitionStrategy);
NearCachingHook invalidationHook = newNearCachingHook();
invalidationHook.beforeRemoteCall(key, keyData, null, null);
Data data = removeInternal(keyData, invalidationHook);
if (data != null || txMap.containsKey(keyData)) {
txMap.put(keyData, new TxnValueWrapper(toObjectIfNeeded(data), Type.REMOVED));
}
}
use of com.hazelcast.internal.nearcache.impl.NearCachingHook in project hazelcast by hazelcast.
the class TransactionalMapProxy method set.
@Override
public void set(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);
Data dataBeforeTxn = putInternal(keyData, valueData, UNSET, MILLISECONDS, invalidationHook);
Type type = dataBeforeTxn == null ? Type.NEW : Type.UPDATED;
TxnValueWrapper wrapper = new TxnValueWrapper(value, type);
txMap.put(keyData, wrapper);
}
use of com.hazelcast.internal.nearcache.impl.NearCachingHook in project hazelcast by hazelcast.
the class TransactionalMapProxy method put.
@Override
public Object put(Object key, Object value, long ttl, TimeUnit timeUnit) {
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);
Object valueBeforeTxn = toObjectIfNeeded(putInternal(keyData, valueData, ttl, timeUnit, invalidationHook));
TxnValueWrapper currentValue = txMap.get(keyData);
Type type = valueBeforeTxn == null ? Type.NEW : Type.UPDATED;
TxnValueWrapper wrapper = new TxnValueWrapper(value, type);
txMap.put(keyData, wrapper);
return currentValue == null ? valueBeforeTxn : checkIfRemoved(currentValue);
}
use of com.hazelcast.internal.nearcache.impl.NearCachingHook in project hazelcast by hazelcast.
the class TransactionalMapProxy method replace.
@Override
public Object replace(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 null;
}
putInternal(keyData, valueData, UNSET, MILLISECONDS, invalidationHook);
txMap.put(keyData, new TxnValueWrapper(value, Type.UPDATED));
return wrapper.value;
} else {
Data oldValue = replaceInternal(keyData, valueData, invalidationHook);
if (oldValue != null) {
txMap.put(keyData, new TxnValueWrapper(value, Type.UPDATED));
}
return toObjectIfNeeded(oldValue);
}
}
Aggregations