private void searchAndLoad(EntryEventImpl event, TXStateInterface txState, Object localValue,
      boolean preferCD) throws CacheLoaderException, TimeoutException {

    RegionAttributes attrs = region.getAttributes();
    Scope scope = attrs.getScope();
    DataPolicy dataPolicy = attrs.getDataPolicy();

    if (txState != null) {
      TXEntryState tx = txState.txReadEntry(event.getKeyInfo(), region, false,
          true/* create txEntry is absent */);
      if (tx != null) {
        if (tx.noValueInSystem()) {
          // If the tx view has it invalid or destroyed everywhere
          // then don't do a netsearch. We want to see the
          // transactional view.
          load(event, preferCD);
          return;
        }
      }
    }

    // if mirrored then we can optimize by skipping netsearch in some cases,
    // and if also skip netSearch if we find an INVALID token since we
    // know it was distributed. (Otherwise it would be a LOCAL_INVALID token)
    {
      if (localValue == Token.INVALID || dataPolicy.withReplication()) {
        load(event, preferCD);
        return;
      }
    }

    Object obj = null;
    if (!scope.isGlobal()) {
      // copy into local var to prevent race condition
      CacheLoader loader = region.basicGetLoader();
      if (loader != null) {
        obj = doLocalLoad(loader, true, preferCD);
        Assert.assertTrue(obj != Token.INVALID && obj != Token.LOCAL_INVALID);
        event.setNewValue(obj);
        isSerialized = false;
        result = obj;
        return;
      }
      if (scope.isLocal()) {
        return;
      }
    }
    netSearchForBlob();
    if (result != null) {
      Assert.assertTrue(result != Token.INVALID && result != Token.LOCAL_INVALID);
      if (isSerialized) {
        event.setSerializedNewValue((byte[]) result);
      } else {
        event.setNewValue(result);
      }
      event.setVersionTag(versionTag);
      return;
    }

    load(event, preferCD);
  }
If we have a local cache loader and the region is not global, then invoke the loader If the
region is local, or the result is non-null, then return whatever the loader returned do a
netSearch amongst selected peers if netSearch returns a blob, deserialize the blob and return
that as the result netSearch failed, so all we can do at this point is do a load return result
from load
geode-core/src/main/java/org/apache/geode/internal/cache/SearchLoadAndWriteProcessor.java