1f5e4d26dSAaron Stone<?xml version="1.0" encoding="US-ASCII"?>
26fd3c40cSAaron Stone<!DOCTYPE rfc SYSTEM "xml2rfc/rfc2629.dtd">
36fd3c40cSAaron Stone<?xml-stylesheet type='text/xsl' href='xml2rfc/rfc2629.xslt'?>
4f5e4d26dSAaron Stone<?rfc toc="yes"?>
5f5e4d26dSAaron Stone<?rfc strict="yes"?>
6f5e4d26dSAaron Stone<?rfc symrefs="yes"?>
7f5e4d26dSAaron Stone<?rfc sortrefs="yes" ?>
8f5e4d26dSAaron Stone<?rfc compact="yes" ?>
9f5e4d26dSAaron Stone<?rfc subcompact="yes" ?>
10*b1d56b4dSSteve Wills<rfc category="info" docName="draft-stone-memcache-udp-01" ipr="trust200902">
11f5e4d26dSAaron Stone
12f5e4d26dSAaron Stone  <front>
13f5e4d26dSAaron Stone
14f5e4d26dSAaron Stone    <title abbrev="Memcache Over UDP"> Memcache Binary Protocol: Extensions for UDP </title>
15f5e4d26dSAaron Stone
16f5e4d26dSAaron Stone    <author fullname="Aaron Stone" surname="Aaron Stone" role="editor">
17f5e4d26dSAaron Stone      <organization>Six Apart, Ltd.</organization>
18f5e4d26dSAaron Stone      <address>
19f5e4d26dSAaron Stone        <postal>
20f5e4d26dSAaron Stone          <street>548 4th Street</street>
21f5e4d26dSAaron Stone          <city>San Francisco</city>
22f5e4d26dSAaron Stone          <region>CA</region>
23f5e4d26dSAaron Stone          <code>94107</code>
24f5e4d26dSAaron Stone          <country>USA</country>
25f5e4d26dSAaron Stone        </postal>
26f5e4d26dSAaron Stone        <email>[email protected]</email>
27f5e4d26dSAaron Stone      </address>
28f5e4d26dSAaron Stone    </author>
29f5e4d26dSAaron Stone
30f5e4d26dSAaron Stone    <date day="14" month="December" year="2007" />
31f5e4d26dSAaron Stone
32f5e4d26dSAaron Stone    <area>Applications</area>
33f5e4d26dSAaron Stone
34f5e4d26dSAaron Stone    <keyword>memcache memcached cache udp</keyword>
35f5e4d26dSAaron Stone
36f5e4d26dSAaron Stone    <abstract>
37f5e4d26dSAaron Stone      <t>
38f5e4d26dSAaron Stone      This memo explains extensions to the memcache binary protocol for use in a UDP environment.
39f5e4d26dSAaron Stone      </t>
40f5e4d26dSAaron Stone
41f5e4d26dSAaron Stone      <t>
42f5e4d26dSAaron Stone      Memcache is a high performance key-value cache. It is intentionally a
43f5e4d26dSAaron Stone      dumb cache, optimized for speed only. Applications using memcache do
44f5e4d26dSAaron Stone      not rely on it for data -- a persistent database with guaranteed reliability
45f5e4d26dSAaron Stone      is strongly recommended -- but applications can run much faster when
46f5e4d26dSAaron Stone      cached data is available in memcache.
47f5e4d26dSAaron Stone      </t>
48f5e4d26dSAaron Stone    </abstract>
49f5e4d26dSAaron Stone  </front>
50f5e4d26dSAaron Stone
51f5e4d26dSAaron Stone  <middle>
52f5e4d26dSAaron Stone    <section anchor="introduction" title="Introduction">
53f5e4d26dSAaron Stone      <t>
54f5e4d26dSAaron Stone      Memcache is a high performance key-value cache. It is intentionally a
55f5e4d26dSAaron Stone      dumb cache, optimized for speed only. Applications using memcache do
56f5e4d26dSAaron Stone      not rely on it for data -- a persistent database with guaranteed reliability
57f5e4d26dSAaron Stone      is strongly recommended -- but applications can run much faster when
58f5e4d26dSAaron Stone      cached data is available in memcache.
59f5e4d26dSAaron Stone      </t>
60f5e4d26dSAaron Stone      <t>
61f5e4d26dSAaron Stone      Sites may find that, due to their network architecture or application usage patterns,
62f5e4d26dSAaron Stone      the stateless <xref target="UDP"/> protocol better suits their needs. This document
63f5e4d26dSAaron Stone      provides extensions and descriptions of use of the <xref target="MEMCACHE">memcache protocol</xref>
64f5e4d26dSAaron Stone      in a UDP environment.
65f5e4d26dSAaron Stone      </t>
66f5e4d26dSAaron Stone      <t>
67f5e4d26dSAaron Stone      It is a goal of this document to provide sufficient information in each UDP packet
68f5e4d26dSAaron Stone      as to avoid any requirement for statefulness on the part of the server nor significant
69f5e4d26dSAaron Stone      caching of outstanding packets on the part of the client.
70f5e4d26dSAaron Stone      </t>
71f5e4d26dSAaron Stone      <section anchor="conventions" title="Conventions Used In This Document">
72f5e4d26dSAaron Stone        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
73f5e4d26dSAaron Stone        "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
74f5e4d26dSAaron Stone        document are to be interpreted as described in <xref target="KEYWORDS"/>.
75f5e4d26dSAaron Stone        </t>
76f5e4d26dSAaron Stone      </section>
77f5e4d26dSAaron Stone    </section>
78f5e4d26dSAaron Stone
79f5e4d26dSAaron Stone    <section anchor="values" title="Defined Values">
80f5e4d26dSAaron Stone      <section anchor="value-magic" title="Magic Byte">
81f5e4d26dSAaron Stone        <t>
82f5e4d26dSAaron Stone        The magic bytes remains the same as in <xref target="MEMCACHE"/>.
83f5e4d26dSAaron Stone        </t>
84f5e4d26dSAaron Stone      </section>
85f5e4d26dSAaron Stone
86f5e4d26dSAaron Stone      <section anchor="value-status" title="Response Status">
87f5e4d26dSAaron Stone        <t>
88f5e4d26dSAaron Stone        Additional status values:
89f5e4d26dSAaron Stone        <list hangIndent="8" style="hanging">
90f5e4d26dSAaron Stone          <t hangText="0x0004">Value is larger than a single response packet</t>
91f5e4d26dSAaron Stone        </list>
92f5e4d26dSAaron Stone        </t>
93f5e4d26dSAaron Stone      </section>
94f5e4d26dSAaron Stone
95f5e4d26dSAaron Stone      <section anchor="value-opcodes" title="Command Opcodes">
96f5e4d26dSAaron Stone        <t>
97f5e4d26dSAaron Stone        Additional opcode values:
98f5e4d26dSAaron Stone        <list hangIndent="8" style="hanging">
99f5e4d26dSAaron Stone          <t hangText="0x0C">Get Range</t>
100f5e4d26dSAaron Stone          <t hangText="0x0D">Set Range</t>
101f5e4d26dSAaron Stone        </list>
102f5e4d26dSAaron Stone        </t>
103f5e4d26dSAaron Stone      </section>
104f5e4d26dSAaron Stone
105f5e4d26dSAaron Stone      <section anchor="value-types" title="Data Types">
106f5e4d26dSAaron Stone        <t>
107f5e4d26dSAaron Stone        There are no new data types in this extension.
108f5e4d26dSAaron Stone        </t>
109f5e4d26dSAaron Stone      </section>
110f5e4d26dSAaron Stone    </section>
111f5e4d26dSAaron Stone
112f5e4d26dSAaron Stone    <section anchor="commands" title="Commands">
113f5e4d26dSAaron Stone
114f5e4d26dSAaron Stone      <section anchor="command-get" title="Get Response">
115f5e4d26dSAaron Stone        <t>
116f5e4d26dSAaron Stone        This section extends the behavior of the Get and GetQ commands as described in
117f5e4d26dSAaron Stone        <xref target="MEMCACHE" x:sec="command-get"/>.
118f5e4d26dSAaron Stone        </t>
119f5e4d26dSAaron Stone
120f5e4d26dSAaron Stone        <t>
121f5e4d26dSAaron Stone        When a Get or GetQ request is made via UDP, and the value of the key for which
122f5e4d26dSAaron Stone        the request was made is larger than can be placed into a single UDP packet (noting
123f5e4d26dSAaron Stone        that the protocol header must also be counted), a Get Range response packet
124f5e4d26dSAaron Stone        MUST be sent instead of the Get response packet. In this instance:
125f5e4d26dSAaron Stone        <list style="numbers">
126f5e4d26dSAaron Stone          <t>The Status field of the response header MUST be 0x0004.</t>
127f5e4d26dSAaron Stone          <t>The Offset field of the GetR response extras MUST be 0.</t>
128f5e4d26dSAaron Stone          <t>The Length field of the GetR response extras, and the data contained in
129f5e4d26dSAaron Stone             the Value field of the packet, SHOULD be the maximum
130f5e4d26dSAaron Stone             allowed length of a UDP packet, less the space required by the header
131f5e4d26dSAaron Stone             and extras; however it MAY be any amount below this maximum.</t>
132f5e4d26dSAaron Stone          <t>The Total value length field of the response extras MUST be the
133f5e4d26dSAaron Stone             actual length of the complete value.</t>
134f5e4d26dSAaron Stone        </list>
135f5e4d26dSAaron Stone        </t>
136f5e4d26dSAaron Stone
137f5e4d26dSAaron Stone        <t>
138f5e4d26dSAaron Stone        The client, upon receipt of a Get Range response bearing Status 0x004
139f5e4d26dSAaron Stone        and a Message ID corresponding to its Get request, shall then know that
140f5e4d26dSAaron Stone        it has received only the first portion of the value. The client MAY choose
141f5e4d26dSAaron Stone        to request the remaining portion of the value by sending one or more Get Range requests.
142f5e4d26dSAaron Stone        </t>
143f5e4d26dSAaron Stone      </section>
144f5e4d26dSAaron Stone
145f5e4d26dSAaron Stone      <section anchor="command-getr-request" title="Get Range Request">
146f5e4d26dSAaron Stone        <t>
147f5e4d26dSAaron Stone	  The Get Range request is primarily intended for use over a UDP transport
148f5e4d26dSAaron Stone	  to request byte ranges of the value for a key. In the event that the Data version
149f5e4d26dSAaron Stone	  check fails to match that of the key, an error MUST be returned.
150f5e4d26dSAaron Stone	</t>
151f5e4d26dSAaron Stone        <t>
152f5e4d26dSAaron Stone      <figure>
153f5e4d26dSAaron Stone        <preamble>Extra data for get range request:</preamble>
154f5e4d26dSAaron Stone          <artwork>
155f5e4d26dSAaron StoneByte/     0       |       1       |       2       |       3       |
156f5e4d26dSAaron Stone   /              |               |               |               |
157f5e4d26dSAaron Stone  |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|
158f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
159f5e4d26dSAaron Stone 0| Flags                                                         |
160f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
161f5e4d26dSAaron Stone 4| Data version check                                            |
162f5e4d26dSAaron Stone  |                                                               |
163f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
164f5e4d26dSAaron Stone12| Offset                                                        |
165f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
166f5e4d26dSAaron Stone16| Length                                                        |
167f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
168f5e4d26dSAaron StoneTotal 20 bytes
169f5e4d26dSAaron Stone      </artwork></figure>
170f5e4d26dSAaron Stone        </t>
171f5e4d26dSAaron Stone      </section>
172f5e4d26dSAaron Stone
173f5e4d26dSAaron Stone      <section anchor="command-getr-response" title="Get Range Response">
174f5e4d26dSAaron Stone        <t>
175f5e4d26dSAaron Stone	  The Get Range request is primarily intended for use over a UDP transport
176f5e4d26dSAaron Stone	  to indicate the location of the bytes of the value for a key contained in
177f5e4d26dSAaron Stone	  a given packet. A client receives enough information in each Get Range
178f5e4d26dSAaron Stone	  extras to construct an appropriately sized buffer in its own memory and
179f5e4d26dSAaron Stone	  blindly insert the contents of the packet at the given byte offset.
180f5e4d26dSAaron Stone	</t>
181f5e4d26dSAaron Stone        <t>
182f5e4d26dSAaron Stone      <figure>
183f5e4d26dSAaron Stone        <preamble>Extra data for get range response:</preamble>
184f5e4d26dSAaron Stone          <artwork>
185f5e4d26dSAaron StoneByte/     0       |       1       |       2       |       3       |
186f5e4d26dSAaron Stone   /              |               |               |               |
187f5e4d26dSAaron Stone  |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|
188f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
189f5e4d26dSAaron Stone 0| Flags                                                         |
190f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
191f5e4d26dSAaron Stone 4| Data version check                                            |
192f5e4d26dSAaron Stone  |                                                               |
193f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
194f5e4d26dSAaron Stone12| Offset                                                        |
195f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
196f5e4d26dSAaron Stone16| Length                                                        |
197f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
198f5e4d26dSAaron Stone20| Total value length                                            |
199f5e4d26dSAaron Stone  +---------------+---------------+---------------+---------------+
200f5e4d26dSAaron StoneTotal 24 bytes
201f5e4d26dSAaron Stone      </artwork></figure>
202f5e4d26dSAaron Stone        </t>
203f5e4d26dSAaron Stone      </section>
204f5e4d26dSAaron Stone
205f5e4d26dSAaron Stone    </section>
206f5e4d26dSAaron Stone
207f5e4d26dSAaron Stone    <section anchor="security" title="Security Considerations">
208f5e4d26dSAaron Stone      <t>
209f5e4d26dSAaron Stone      This document does not introduce any new security considerations
210f5e4d26dSAaron Stone      beyond those discussed in <xref target="MEMCACHE" x:sec="security"/>.
211f5e4d26dSAaron Stone      </t>
212f5e4d26dSAaron Stone    </section>
213f5e4d26dSAaron Stone
214f5e4d26dSAaron Stone  </middle>
215f5e4d26dSAaron Stone
216f5e4d26dSAaron Stone  <back>
217f5e4d26dSAaron Stone    <references title="Normative References">
218618d23a4SSteve Wills      <dwdrfc-ref anchor='UDP' src='reference.RFC.0768.xml'/>
219618d23a4SSteve Wills      <dwdrfc-ref anchor='KEYWORDS' src='reference.RFC.2119.xml'/>
220f5e4d26dSAaron Stone      <!-- FIXME: Get a draft reference for the base document. -->
221618d23a4SSteve Wills      <dwdrfc-ref anchor='MEMCACHE' src='reference.RFC.2119.xml'/>
222f5e4d26dSAaron Stone    </references>
223f5e4d26dSAaron Stone  </back>
224f5e4d26dSAaron Stone
225f5e4d26dSAaron Stone</rfc>
226f5e4d26dSAaron Stone
227