Example usage for io.netty.handler.codec.memcache.binary FullBinaryMemcacheRequest setCas

List of usage examples for io.netty.handler.codec.memcache.binary FullBinaryMemcacheRequest setCas

Introduction

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

Prototype

BinaryMemcacheMessage setCas(long cas);

Source Link

Document

Sets the CAS identifier.

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  w w .j  av  a 2  s . co 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;
}