Example usage for io.netty.handler.codec.memcache.binary BinaryMemcacheOpcodes REPLACE

List of usage examples for io.netty.handler.codec.memcache.binary BinaryMemcacheOpcodes REPLACE

Introduction

In this page you can find the example usage for io.netty.handler.codec.memcache.binary BinaryMemcacheOpcodes REPLACE.

Prototype

byte REPLACE

To view the source code for io.netty.handler.codec.memcache.binary BinaryMemcacheOpcodes REPLACE.

Click Source Link

Usage

From source file:com.couchbase.client.core.endpoint.binary.BinaryCodec.java

License:Open Source License

/**
 * Creates the actual protocol level request for an incoming replacer request.
 *
 * @param request the incoming replace request.
 * @param ctx the channel handler context for buffer allocations.
 * @return the built protocol request.//from w ww .  j a v  a 2  s  .c o  m
 */
private BinaryMemcacheRequest handleReplaceRequest(final ReplaceRequest request,
        final ChannelHandlerContext ctx) {
    ByteBuf extras = ctx.alloc().buffer(8);
    extras.writeInt(request.flags());
    extras.writeInt(request.expiration());

    FullBinaryMemcacheRequest msg = new DefaultFullBinaryMemcacheRequest(request.key(), extras,
            request.content());

    msg.setOpcode(BinaryMemcacheOpcodes.REPLACE);
    msg.setCAS(request.cas());
    msg.setKeyLength((short) request.key().length());
    msg.setTotalBodyLength(
            (short) request.key().length() + request.content().readableBytes() + extras.readableBytes());
    msg.setReserved(request.partition());
    msg.setExtrasLength((byte) extras.readableBytes());
    return msg;
}