}
private Object realRemoteGet(InvocationContext ctx, Object key, boolean storeInL1, boolean isWrite) throws Throwable {
if (trace) log.tracef("Doing a remote get for key %s", key);
// attempt a remote lookup
InternalCacheEntry ice = dm.retrieveFromRemoteSource(key, ctx);
if (ice != null) {
if (storeInL1) {
if (isL1CacheEnabled) {
if (trace) log.tracef("Caching remotely retrieved entry for key %s in L1", key);
long lifespan = ice.getLifespan() < 0 ? configuration.getL1Lifespan() : Math.min(ice.getLifespan(), configuration.getL1Lifespan());
PutKeyValueCommand put = cf.buildPutKeyValueCommand(ice.getKey(), ice.getValue(), lifespan, -1, ctx.getFlags());
entryFactory.wrapEntryForWriting(ctx, key, true, false, ctx.hasLockedKey(key), false, false);
invokeNextInterceptor(ctx, put);
} else {
CacheEntry ce = ctx.lookupEntry(key);
if (ce == null || ce.isNull() || ce.isLockPlaceholder() || ce.getValue() == null) {
if (ce != null && ce.isChanged()) {
ce.setValue(ice.getValue());
} else {
if (isWrite)
entryFactory.wrapEntryForWriting(ctx, ice, true, false, ctx.hasLockedKey(key), false, false);
else
ctx.putLookedUpEntry(key, ice);
}
}
}
} else {
if (trace) log.tracef("Not caching remotely retrieved entry for key %s in L1", key);
}
return ice.getValue();
}
return null;
}