public ByteBuf writeRequest()

in folsom/src/main/java/com/spotify/folsom/client/binary/SetRequest.java [59:81]


  public ByteBuf writeRequest(final ByteBufAllocator alloc, final ByteBuffer dst) {
    final int expiration = Utils.ttlToExpiration(ttl);

    final int valueLength = value.length;

    final boolean hasExtra =
        (opcode == OpCode.SET || opcode == OpCode.ADD || opcode == OpCode.REPLACE);

    final int extraLength = hasExtra ? 8 : 0;

    writeHeader(dst, opcode, extraLength, valueLength, cas);
    if (hasExtra) {
      dst.putInt(flags); // byte 24-27, flags
      dst.putInt(expiration); // byte 28-31, expiration
    }
    dst.put(key);
    if (dst.remaining() >= valueLength) {
      dst.put(value);
      return toBuffer(alloc, dst);
    } else {
      return toBufferWithValue(alloc, dst, value);
    }
  }