in folsom/src/main/java/com/spotify/folsom/client/ascii/SetRequest.java [98:120]
public ByteBuf writeRequest(ByteBufAllocator alloc, ByteBuffer dst) {
// <command name> <key> <flags> <exptime> <bytes> [noreply]\r\n
// "cas" <key> <flags> <exptime> <cas unique> <bytes> [noreply]\r\n
dst.put(CMD.get(operation));
dst.put(key);
dst.put(toFlags(flags));
dst.put(String.valueOf(Utils.ttlToExpiration(ttl)).getBytes());
dst.put(SPACE_BYTES);
dst.put(String.valueOf(value.length).getBytes());
if (operation == Operation.CAS) {
dst.put(SPACE_BYTES);
dst.put(String.valueOf(cas).getBytes());
}
dst.put(NEWLINE_BYTES);
if (dst.remaining() >= value.length + NEWLINE_BYTES.length) {
dst.put(value);
dst.put(NEWLINE_BYTES);
return toBuffer(alloc, dst);
} else {
return toBufferWithValueAndNewLine(alloc, dst, value);
}
}