compared with
Version 13 by Steve Yen
on Jul 16, 2012 12:01.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (2)

View Page History
The XDCR binary protocol consists of the add with meta, get with meta, set with meta, and delete with meta commands. Their binary format is defined below.

h2. Set With Meta

{code:none}
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| 0x80 | 0xa2 | 0x00 | 0x05 |
+---------------+---------------+---------------+---------------+
4| 0x14 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
8| 0x00 | 0x00 | 0x00 | 0x20 |
+---------------+---------------+---------------+---------------+
12| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
16| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
20| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
24| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
28| 0x00 | 0x00 | 0x00 | 0x0a |
+---------------+---------------+---------------+---------------+
32| 0xbe | 0xef | 0xca | 0xfe |
+---------------+---------------+---------------+---------------+
36| 0xde | 0xad | 0xba | 0xbe |
+---------------+---------------+---------------+---------------+
40| 0xca | 0xfe | 0xba | 0xbe |
+---------------+---------------+---------------+---------------+
44| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
48| 0x6d ('m') | 0x79 ('y') | 0x6b ('k') | 0x65 ('e') |
+---------------+---------------+---------------+---------------+
52| 0x79 ('y') | 0x6d ('m') | 0x79 ('y') | 0x76 ('v') |
+---------------+---------------+---------------+---------------+
56| 0x61 ('a') | 0x6c ('l') | 0x75 ('u') | 0x65 ('e') |
+---------------+---------------+---------------+---------------+

set with meta command
Field (offset) (value)
Magic (0) : 0x80
Opcode (1) : 0xa2
Key length (2,3) : 0x0005
Extra length (4) : 0x14
Data type (5) : 0x00
Vbucket (6,7) : 0x0000
Total body (8-11) : 0x00000020 == 0x14 + 5 + 7
Opaque (12-15): 0xdeadbeef
CAS (16-23): 0x0000000000000000
Flags (24-27): 0x00000000
Expiration (28-31): 0x0000000a
Seqno (32-39): 0xbeefcafedeadbabe
Remote CAS (40-47): 0xcafebabedeadbeef
Key (48-52): mykey
Value (53-59): myvalue
{code}

Note that the format above can be used with different opcodes to define slightly different behavior. These opcodes define setq with meta (0xa3), add with meta (0xa4), and addq with meta (0xa5).

h2. Delete With Meta

{code:none}
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| 0x80 | 0xa8 | 0x00 | 0x05 |
+---------------+---------------+---------------+---------------+
4| 0x14 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
8| 0x00 | 0x00 | 0x00 | 0x19 |
+---------------+---------------+---------------+---------------+
12| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
16| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
20| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
24| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
28| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
32| 0xbe | 0xef | 0xca | 0xfe |
+---------------+---------------+---------------+---------------+
36| 0xde | 0xad | 0xba | 0xbe |
+---------------+---------------+---------------+---------------+
40| 0xca | 0xfe | 0xba | 0xbe |
+---------------+---------------+---------------+---------------+
44| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
48| 0x6d ('m') | 0x79 ('y') | 0x6b ('k') | 0x65 ('e') |
+---------------+---------------+---------------+---------------+
52| 0x79 ('y') |
+---------------+

delete with meta command
Field (offset) (value)
Magic (0) : 0x80
Opcode (1) : 0xa8
Key length (2,3) : 0x0005
Extra length (4) : 0x14
Data type (5) : 0x00
Vbucket (6,7) : 0x0000
Total body (8-11) : 0x00000019 == 0x14 + 5 + 0
Opaque (12-15): 0xdeadbeef
CAS (16-23): 0x0000000000000000
Flags (24-27): 0x00000000
Expiration (28-31): 0x00000000
Seqno (32-39): 0xbeefcafedeadbabe
Remote CAS (40-47): 0xcafebabedeadbeef
Key (48-52): mykey
{code}

For deleteq with meta use opcode 0xa9.
See the http://www.couchbase.com/wiki/display/couchbase/SET-WITH-META+protocol page if you're interested in SET-WITH-META