@Override
  public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
      throws Throwable {

    // This method will get the put() calls on the cache and then send them into Lucene once it's
    // successful.
    // do the actual put first.
    Object toReturn = invokeNextInterceptor(ctx, command);

    if (shouldModifyIndexes(ctx)) {
      // First making a check to see if the key is already in the cache or not. If it isn't we can
      // add the key no problem,
      // otherwise we need to be updating the indexes as opposed to simply adding to the indexes.
      getLog().debug("Infinispan Query indexing is triggered");
      Object key = command.getKey();
      Object value = extractValue(command.getValue());

      if (updateKnownTypesIfNeeded(value)) {
        // This means that the entry is just modified so we need to update the indexes and not add
        // to them.
        updateIndexes(value, extractValue(key));
      } else {
        if (updateKnownTypesIfNeeded(toReturn)) {
          removeFromIndexes(toReturn, extractValue(command.getKey()));
        }
      }
    }
    return toReturn;
  }
 /**
  * Indexing management of a PutKeyValueCommand
  *
  * @param command the visited PutKeyValueCommand
  * @param ctx the InvocationContext of the PutKeyValueCommand
  * @param previousValue the value being replaced by the put operation
  * @param transactionContext Optional for lazy initialization, or reuse an existing context.
  */
 private void processPutKeyValueCommand(
     final PutKeyValueCommand command,
     final InvocationContext ctx,
     final Object previousValue,
     TransactionContext transactionContext) {
   final boolean usingSkipIndexCleanupFlag = usingSkipIndexCleanup(command);
   // whatever the new type, we might still need to cleanup for the previous value (and schedule
   // removal first!)
   Object value = extractValue(command.getValue());
   if (!usingSkipIndexCleanupFlag
       && updateKnownTypesIfNeeded(previousValue)
       && shouldRemove(value, previousValue)) {
     if (shouldModifyIndexes(command, ctx)) {
       transactionContext =
           transactionContext == null ? makeTransactionalEventContext() : transactionContext;
       removeFromIndexes(previousValue, extractValue(command.getKey()), transactionContext);
     }
   }
   if (updateKnownTypesIfNeeded(value)) {
     if (shouldModifyIndexes(command, ctx)) {
       // This means that the entry is just modified so we need to update the indexes and not add
       // to them.
       transactionContext =
           transactionContext == null ? makeTransactionalEventContext() : transactionContext;
       updateIndexes(
           usingSkipIndexCleanupFlag, value, extractValue(command.getKey()), transactionContext);
     }
   }
 }
 @Override
 public BasicInvocationStage visitPutKeyValueCommand(
     InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
   if (streamSummaryContainer.isEnabled() && ctx.isOriginLocal()) {
     streamSummaryContainer.addPut(command.getKey(), isRemote(command.getKey()));
   }
   return invokeNext(ctx, command).handle(writeSkewReturnHandler);
 }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   log.tracef("Processing a remote put %s", command);
   if (command.isConditional()) {
     return backupCache.putIfAbsent(command.getKey(), command.getValue(), command.getMetadata());
   }
   return backupCache.put(command.getKey(), command.getValue(), command.getMetadata());
 }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   if (cdl.localNodeIsOwner(command.getKey())) {
     entryFactory.wrapEntryForWriting(
         ctx, command.getKey(), EntryFactory.Wrap.WRAP_ALL, false, false);
     ctx.forkInvocationSync(command);
   }
   return null;
 }
  @Override
  public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
      throws Throwable {
    SingleKeyRecipientGenerator skrg = new SingleKeyRecipientGenerator(command.getKey());
    Object returnValue = handleWriteCommand(ctx, command, skrg, false, false);
    // If this was a remote put record that which sent it
    if (isL1CacheEnabled
        && !ctx.isOriginLocal()
        && !skrg.generateRecipients().contains(ctx.getOrigin()))
      l1Manager.addRequestor(command.getKey(), ctx.getOrigin());

    return returnValue;
  }
  @Override
  public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
      throws Throwable {
    Object returnValue = invokeNextInterceptor(ctx, command);
    Object key = command.getKey();
    if (!isStoreEnabled(command) || ctx.isInTxScope() || !command.isSuccessful())
      return returnValue;
    if (!isProperWriter(ctx, command, command.getKey())) return returnValue;

    InternalCacheEntry se = getStoredEntry(key, ctx);
    store.store(se);
    log.tracef("Stored entry %s under key %s", se, key);
    if (getStatisticsEnabled()) cacheStores.incrementAndGet();
    return returnValue;
  }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   if (isStoreAsBinary() || isClusterInvocation(ctx) || isStoreInvocation(ctx))
     checkMarshallable(command.getKey(), command.getValue());
   return super.visitPutKeyValueCommand(ctx, command);
 }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   if (!isPutForExternalRead(ctx)) {
     return handleInvalidate(ctx, command, command.getKey());
   }
   return invokeNextInterceptor(ctx, command);
 }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   if (ctx.isOriginLocal()) {
     Entity entity = extractEntity(command.getValue());
     EntryVersion entryVersion = getEntryVersion(ctx, command.getKey());
     applyVersion(entity, entryVersion);
   }
   return invokeNextInterceptor(ctx, command);
 }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   processCommand(command);
   containsPutForExternalRead =
       containsPutForExternalRead
           || (command.getFlags() != null
               && command.getFlags().contains(Flag.PUT_FOR_EXTERNAL_READ));
   result.add(command.getKey());
   return null;
 }
 @Override
 public CompletableFuture<Void> visitPutKeyValueCommand(
     InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
   return visitWriteCommand(ctx, command, command.getKey());
 }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   result.add(command.getKey());
   return null;
 }
 @Override
 public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
     throws Throwable {
   SingleKeyRecipientGenerator skrg = new SingleKeyRecipientGenerator(command.getKey());
   return handleWriteCommand(ctx, command, skrg, false, false);
 }