return visitor.visitRemoveCommand(ctx, this);
}
@Override
public Object perform(InvocationContext ctx) throws Throwable {
CacheEntry e = ctx.lookupEntry(key);
if (e == null || e.isNull()) {
nonExistent = true;
log.trace("Nothing to remove since the entry is null or we have a null entry");
if (value == null) {
return null;
} else {
successful = false;
return false;
}
}
if (!(e instanceof MVCCEntry)) ctx.putLookedUpEntry(key, null);
if (value != null && e.getValue() != null && !e.getValue().equals(value)) {
successful = false;
e.rollback();
return false;
}
final Object removedValue = e.getValue();
notify(ctx, removedValue, true);
e.setRemoved(true);
e.setValid(false);
// Eviction has no notion of pre/post event since 4.2.0.ALPHA4.
// EvictionManagerImpl.onEntryEviction() triggers both pre and post events
// with non-null values, so we should do the same here as an ugly workaround.
if (this instanceof EvictCommand) {
e.setEvicted(true);
notify(ctx, removedValue, false);
} else {
// FIXME: Do we really need to notify with null when a user can be given with more information?
notify(ctx, null, false);
}