protected KeyWrapper getKey(ByteBuffer buffer, int keyStartIndex) {
    int keyLength = buffer.getShort(KEY_LENGTH_INDEX);
    if (getLogger().finerEnabled()) {
      getLogger().finer("keyLength:" + keyLength);
    }
    byte[] key = new byte[keyLength];
    buffer.position(keyStartIndex);
    buffer.get(key);
    // for (int i=0; i<keyLength; i++) {
    // key[i] = buffer.get();
    // }
    if (getLogger().finerEnabled()) {
      getLogger().finer("key:" + Arrays.toString(key));
    }
    return KeyWrapper.getWrappedKey(key);
  }
A buffer to read and decode the first line.
geode-memcached/src/main/java/org/apache/geode/internal/memcached/commands/AbstractCommand.java