1
<?xml version="1.0" encoding="US-ASCII"?>
2
<!DOCTYPE rfc SYSTEM "xml2rfc/rfc2629.dtd">
3
<?xml-stylesheet type='text/xsl' href='xml2rfc/rfc2629.xslt'?>
7
<?rfc sortrefs="yes" ?>
9
<?rfc subcompact="yes" ?>
10
<rfc category="info" docName="draft-stone-memcache-udp-01" ipr="none">
14
<title abbrev="Memcache Over UDP"> Memcache Binary Protocol: Extensions for UDP </title>
16
<author fullname="Aaron Stone" surname="Aaron Stone" role="editor">
17
<organization>Six Apart, Ltd.</organization>
20
<street>548 4th Street</street>
21
<city>San Francisco</city>
24
<country>USA</country>
26
<email>aaron@serendipity.palo-alto.ca.us</email>
30
<date day="14" month="December" year="2007" />
32
<area>Applications</area>
34
<keyword>memcache memcached cache udp</keyword>
38
This memo explains extensions to the memcache binary protocol for use in a UDP environment.
42
Memcache is a high performance key-value cache. It is intentionally a
43
dumb cache, optimized for speed only. Applications using memcache do
44
not rely on it for data -- a persistent database with guaranteed reliability
45
is strongly recommended -- but applications can run much faster when
46
cached data is available in memcache.
52
<section anchor="introduction" title="Introduction">
54
Memcache is a high performance key-value cache. It is intentionally a
55
dumb cache, optimized for speed only. Applications using memcache do
56
not rely on it for data -- a persistent database with guaranteed reliability
57
is strongly recommended -- but applications can run much faster when
58
cached data is available in memcache.
61
Sites may find that, due to their network architecture or application usage patterns,
62
the stateless <xref target="UDP"/> protocol better suits their needs. This document
63
provides extensions and descriptions of use of the <xref target="MEMCACHE">memcache protocol</xref>
67
It is a goal of this document to provide sufficient information in each UDP packet
68
as to avoid any requirement for statefulness on the part of the server nor significant
69
caching of outstanding packets on the part of the client.
71
<section anchor="conventions" title="Conventions Used In This Document">
72
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
73
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
74
document are to be interpreted as described in <xref target="KEYWORDS"/>.
79
<section anchor="values" title="Defined Values">
80
<section anchor="value-magic" title="Magic Byte">
82
The magic bytes remains the same as in <xref target="MEMCACHE"/>.
86
<section anchor="value-status" title="Response Status">
88
Additional status values:
89
<list hangIndent="8" style="hanging">
90
<t hangText="0x0004">Value is larger than a single response packet</t>
95
<section anchor="value-opcodes" title="Command Opcodes">
97
Additional opcode values:
98
<list hangIndent="8" style="hanging">
99
<t hangText="0x0C">Get Range</t>
100
<t hangText="0x0D">Set Range</t>
105
<section anchor="value-types" title="Data Types">
107
There are no new data types in this extension.
112
<section anchor="commands" title="Commands">
114
<section anchor="command-get" title="Get Response">
116
This section extends the behavior of the Get and GetQ commands as described in
117
<xref target="MEMCACHE" x:sec="command-get"/>.
121
When a Get or GetQ request is made via UDP, and the value of the key for which
122
the request was made is larger than can be placed into a single UDP packet (noting
123
that the protocol header must also be counted), a Get Range response packet
124
MUST be sent instead of the Get response packet. In this instance:
125
<list style="numbers">
126
<t>The Status field of the response header MUST be 0x0004.</t>
127
<t>The Offset field of the GetR response extras MUST be 0.</t>
128
<t>The Length field of the GetR response extras, and the data contained in
129
the Value field of the packet, SHOULD be the maximum
130
allowed length of a UDP packet, less the space required by the header
131
and extras; however it MAY be any amount below this maximum.</t>
132
<t>The Total value length field of the response extras MUST be the
133
actual length of the complete value.</t>
138
The client, upon receipt of a Get Range response bearing Status 0x004
139
and a Message ID corresponding to its Get request, shall then know that
140
it has received only the first portion of the value. The client MAY choose
141
to request the remaining portion of the value by sending one or more Get Range requests.
145
<section anchor="command-getr-request" title="Get Range Request">
147
The Get Range request is primarily intended for use over a UDP transport
148
to request byte ranges of the value for a key. In the event that the Data version
149
check fails to match that of the key, an error MUST be returned.
153
<preamble>Extra data for get range request:</preamble>
155
Byte/ 0 | 1 | 2 | 3 |
157
|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|
158
+---------------+---------------+---------------+---------------+
160
+---------------+---------------+---------------+---------------+
161
4| Data version check |
163
+---------------+---------------+---------------+---------------+
165
+---------------+---------------+---------------+---------------+
167
+---------------+---------------+---------------+---------------+
173
<section anchor="command-getr-response" title="Get Range Response">
175
The Get Range request is primarily intended for use over a UDP transport
176
to indicate the location of the bytes of the value for a key contained in
177
a given packet. A client receives enough information in each Get Range
178
extras to construct an appropriately sized buffer in its own memory and
179
blindly insert the contents of the packet at the given byte offset.
183
<preamble>Extra data for get range response:</preamble>
185
Byte/ 0 | 1 | 2 | 3 |
187
|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|
188
+---------------+---------------+---------------+---------------+
190
+---------------+---------------+---------------+---------------+
191
4| Data version check |
193
+---------------+---------------+---------------+---------------+
195
+---------------+---------------+---------------+---------------+
197
+---------------+---------------+---------------+---------------+
198
20| Total value length |
199
+---------------+---------------+---------------+---------------+
207
<section anchor="security" title="Security Considerations">
209
This document does not introduce any new security considerations
210
beyond those discussed in <xref target="MEMCACHE" x:sec="security"/>.
217
<references title="Normative References">
218
<dwdrfc-ref anchor='UDP' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.0768.xml'/>
219
<dwdrfc-ref anchor='KEYWORDS' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'/>
220
<!-- FIXME: Get a draft reference for the base document. -->
221
<dwdrfc-ref anchor='MEMCACHE' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'/>