binary protocol notes from the facebook hackathon
Trond Norbye
Trond.Norbye at Sun.COM
Wed Jul 11 08:55:53 UTC 2007
Clint Webb wrote:
> I agree. Thats one thing I noticed about the protocol when I was
> reading my email on the train this morning.
>
> Keeping the original structure would make it difficult to change the
> fixed-width parameters given to a command.
>
> Having an offset would mean that the key can be found much easier.
> However, care should be taken that the offset given doesnt go out of
> the bounds of the message. I'm not in total favour of an offset
> either, because in this case, you're basically moving the calculation
> from the server to the client.
>
> What I prefer is:
> * Magic byte / version
> * Cmd byte
> * 4 byte opaque id.
> * Key len byte (if no key, 0)
> * key, if key length above is non-zero.
> * 4 byte body length (not including reserved byte at the end)
> * [ cmd-specific fixed-width fields ]
> * [ cmd-specific variable-width field ]
> * Reserved byte (should be 0)
>
> What I additionally prefer, is a total packet length after the magic
> byte, but that might meet substantially more debate.
>
I would also prefer a total length field. This would let me easily
determine if I have the complete packet or not without searching through
the packet and look for the various length fields...
Trond Norbye
More information about the memcached
mailing list