![JAR search and dependency download from the Maven repository](/logo.png)
org.infinispan.server.resp.commands.tx.DISCARD Maven / Gradle / Ivy
Show all versions of infinispan-server-resp Show documentation
package org.infinispan.server.resp.commands.tx;
import java.util.List;
import java.util.concurrent.CompletionStage;
import org.infinispan.server.resp.Resp3Handler;
import org.infinispan.server.resp.RespCommand;
import org.infinispan.server.resp.RespErrorUtil;
import org.infinispan.server.resp.RespRequestHandler;
import org.infinispan.server.resp.commands.Resp3Command;
import org.infinispan.server.resp.commands.TransactionResp3Command;
import org.infinispan.server.resp.serialization.Resp3Response;
import org.infinispan.server.resp.tx.RespTransactionHandler;
import io.netty.channel.ChannelHandlerContext;
/**
* `DISCARD
` command.
*
* This command clears the queued commands and returns to the normal mode. All the registered listeners are
* removed.
*
* @since 15.0
* @see Redis Documentation
* @author José Bolina
*/
public class DISCARD extends RespCommand implements Resp3Command, TransactionResp3Command {
public DISCARD() {
super(1, 0, 0, 0);
}
@Override
public CompletionStage perform(Resp3Handler handler, ChannelHandlerContext ctx, List arguments) {
RespErrorUtil.customError("DISCARD without MULTI", handler.allocator());
return handler.myStage();
}
@Override
public CompletionStage perform(RespTransactionHandler handler, ChannelHandlerContext ctx, List arguments) {
Resp3Handler next = handler.respServer().newHandler();
return handler.stageToReturn(handler.dropTransaction(ctx), ctx, ignore -> {
Resp3Response.ok(handler.allocator());
return next;
});
}
}