org.infinispan.server.resp.commands.hash.HSET Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-server-resp Show documentation
Show all versions of infinispan-server-resp Show documentation
Infinispan Resp Protocol Server
The newest version!
package org.infinispan.server.resp.commands.hash;
import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.function.BiConsumer;
import org.infinispan.server.resp.ByteBufPool;
import org.infinispan.server.resp.Consumers;
import org.infinispan.server.resp.Resp3Handler;
import org.infinispan.server.resp.RespErrorUtil;
import org.infinispan.server.resp.RespRequestHandler;
import io.netty.channel.ChannelHandlerContext;
/**
* Executes the `HSET key field value [field value ...]
` command.
*
* Sets the specified `field
`-`value
` pairs in the hash stored at the given `key
`.
*
*
* @since 15.0
* @see Redis Documentation
*/
public class HSET extends HMSET {
static final BiConsumer CONSUMER = (r, t) -> Consumers.LONG_BICONSUMER.accept((long) r, t);
@Override
public CompletionStage perform(Resp3Handler handler, ChannelHandlerContext ctx, List arguments) {
// Arguments are the hash map key and N key-value pairs.
if ((arguments.size() & 1) == 0) {
RespErrorUtil.wrongArgumentNumber(this, handler.allocator());
return handler.myStage();
}
return handler.stageToReturn(setEntries(handler, arguments), ctx, CONSUMER);
}
}