binary protocol notes from the facebook hackathon

Dustin Sallings dustin at spy.net
Wed Jul 11 09:01:55 UTC 2007


On Jul 11, 2007, at 1:25, Clint Webb wrote:

> 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)

	Byte alignment is important to some people.  Currently, all bytes  
are guaranteed before the variable length data begins.

	My suggestion to take over the reserved byte doesn't actually make  
much of a difference.  The command specific fixed-width fields is a  
constant for a given command.  Effectively, instead of hard-coding 0,  
you'd hard-code a specific value for a given command.

	Generally, it doesn't matter because we know the number of fixed- 
length fields for defined commands.  It's only valuable when you  
don't know what the command is you're processing.  For example, in a  
wireshark plugin you can display the key for a command that the  
plugin doesn't know about yet.  Or in the case of my test server, I  
can split the chunks up before handing it up to the higher level  
handler.

-- 
Dustin Sallings


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20070711/b3445d05/attachment.htm


More information about the memcached mailing list