exports.toBuffer = function(header) {
var headerBuf = Buffer.alloc(24);
headerBuf.fill();
headerBuf.writeUInt8(header.magic, 0);
headerBuf.writeUInt8(header.opcode, 1);
headerBuf.writeUInt16BE(header.keyLength, 2);
headerBuf.writeUInt8(header.extrasLength, 4);
headerBuf.writeUInt8(header.dataType || 0, 5);
headerBuf.writeUInt16BE(header.status || 0, 6);
headerBuf.writeUInt32BE(header.totalBodyLength, 8);
headerBuf.writeUInt32BE(header.opaque || 0, 12);
if (header.cas) {
header.cas.copy(headerBuf, 16);
} else {
headerBuf.fill('\x00', 16);
}
return headerBuf;
};