Two binary protocol questions (draft, stats)

Trond Norbye Trond.Norbye at Sun.COM
Fri Apr 4 15:17:28 UTC 2008


On Apr 3, 2008, at 8:51 PM, dormando wrote:
> Hey,
>
> - As far as completing the commands for the binary protocol goes, it  
> looks like we're just lacking the stats commands.
>
> I'd like to open the floor to ideas. I know trond's going to submit  
> one later on, but I'm curious if anyone's really thought about this  
> yet.

I had an idea yesterday, but the more I thought of it, the more I  
didn't like it ;-) I don't see a big point in wrapping the textual  
stats into a "binary packet", because then you could just use the  
textual version instead (and the stats command is primarily being used  
by "management tools" so they could use their own connection? or am I  
missing something?)

My suggestion is therefore that we don't create a binary stats right  
now. I think that a better solution is that we implement the binary  
"version" command, and that command returns the protocol version(s)  
that the server supports. By doing so we can release a binary version  
now without some commands, and add support for them later on.

The version command could return something like:
      Byte/     0       |       1       |       2       |        
3       |
         /              |               |                
|               |
        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6  
7|
        +---------------+---------------+--------------- 
+---------------+
       0| Major         | Minor         | Micro         | # proto  
vers  |
        +---------------+---------------+--------------- 
+---------------+
       4| supp proto ver| supp proto ver| supp proto  
ver| ...           |
        +---------------+---------------+--------------- 
+---------------+
        |                
|                                               |
        +---------------+---------------+--------------- 
+---------------+
      n | Rest of data is a "freeform  
textual"                          |
        +---------------+---------------+--------------- 
+---------------+

Example:

(without the standard pcket header)

      Byte/     0       |       1       |       2       |        
3       |
         /              |               |                
|               |
        |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6  
7|
        +---------------+---------------+--------------- 
+---------------+
       0|      0x01     |     0x03      |     0x00      |      
0x01      |
        +---------------+---------------+--------------- 
+---------------+
       4|      0x01     |      'M'      |      'e'      |       
'm'      |
        +---------------+---------------+--------------- 
+---------------+
       8|      'c'      |      'a'      |      'c'      |       
'h'      |
        +---------------+---------------+--------------- 
+---------------+
      12|      'e'      |      'd'      |      ' '      |       
'e'      |
        +---------------+---------------+--------------- 
+---------------+
      16|      'x'      |      'a'      |      'm'      |       
'p'      |
        +---------------+---------------+--------------- 
+---------------+
      16|      'l'      |      'e'      |
        +---------------+---------------+


This is a the header for version 1.3.0 that supports the 1 version of  
the binary protocol with the freeform text: "Memcached example"

Trond



More information about the memcached mailing list