@Override
  public void initialize() {
    int size = (1 + keys.size()) * MIN_RECV_PACKET;
    for (byte[] b : bkeys.values()) {
      size += b.length;
    }
    // set up the initial header stuff
    ByteBuffer bb = ByteBuffer.allocate(size);
    for (Map.Entry<Integer, byte[]> me : bkeys.entrySet()) {
      final byte[] keyBytes = me.getValue();
      final String key = keys.get(me.getKey());

      // Custom header
      bb.put(REQ_MAGIC);
      bb.put(CMD_GETQ);
      bb.putShort((short) keyBytes.length);
      bb.put((byte) 0); // extralen
      bb.put((byte) 0); // data type
      bb.putShort(vbmap.get(key).shortValue()); // vbucket
      bb.putInt(keyBytes.length);
      bb.putInt(me.getKey());
      bb.putLong(0); // cas
      // the actual key
      bb.put(keyBytes);
    }
    // Add the noop
    bb.put(REQ_MAGIC);
    bb.put((byte) NoopOperationImpl.CMD);
    bb.putShort((short) 0);
    bb.put((byte) 0); // extralen
    bb.put((byte) 0); // data type
    bb.putShort((short) 0); // reserved
    bb.putInt(0);
    bb.putInt(terminalOpaque);
    bb.putLong(0); // cas

    bb.flip();
    setBuffer(bb);
  }
Add a key (and return its new opaque value).
src/main/java/net/spy/memcached/protocol/binary/MultiGetOperationImpl.java