Browse Source

Partial command reformulation in protocol doc.

Frederic G. MARAND 6 years ago
parent
commit
e4e0af726c
3 changed files with 228 additions and 44 deletions
  1. 8 8
      .idea/libraries/GOPATH__gache_.xml
  2. 51 36
      .idea/workspace.xml
  3. 169 0
      docs/protocol.yml

+ 8 - 8
.idea/libraries/GOPATH__gache_.xml

@@ -1,22 +1,22 @@
 <component name="libraryTable">
   <library name="GOPATH &lt;gache&gt;">
     <CLASSES>
-      <root url="file://$PROJECT_DIR$/../../../launchpad.net" />
-      <root url="file://$PROJECT_DIR$/../../../golang.org" />
       <root url="file://$PROJECT_DIR$/../../../.idea" />
-      <root url="file://$PROJECT_DIR$/../../../github.com" />
-      <root url="file://$PROJECT_DIR$/../../../gopkg.in" />
       <root url="file://$PROJECT_DIR$/../.." />
+      <root url="file://$PROJECT_DIR$/../../../gopkg.in" />
+      <root url="file://$PROJECT_DIR$/../../../github.com" />
+      <root url="file://$PROJECT_DIR$/../../../golang.org" />
+      <root url="file://$PROJECT_DIR$/../../../launchpad.net" />
       <root url="file://$PROJECT_DIR$/../../../fgm" />
     </CLASSES>
     <JAVADOC />
     <SOURCES>
-      <root url="file://$PROJECT_DIR$/../../../launchpad.net" />
-      <root url="file://$PROJECT_DIR$/../../../golang.org" />
       <root url="file://$PROJECT_DIR$/../../../.idea" />
-      <root url="file://$PROJECT_DIR$/../../../github.com" />
-      <root url="file://$PROJECT_DIR$/../../../gopkg.in" />
       <root url="file://$PROJECT_DIR$/../.." />
+      <root url="file://$PROJECT_DIR$/../../../gopkg.in" />
+      <root url="file://$PROJECT_DIR$/../../../github.com" />
+      <root url="file://$PROJECT_DIR$/../../../golang.org" />
+      <root url="file://$PROJECT_DIR$/../../../launchpad.net" />
       <root url="file://$PROJECT_DIR$/../../../fgm" />
     </SOURCES>
     <excluded>

+ 51 - 36
.idea/workspace.xml

@@ -2,11 +2,9 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="36eaad7a-0726-4217-b7e5-1b2c680697a1" name="Default" comment="">
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/docs/runner_cli.md" />
-      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/docs/runner_config.md" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/docs/protocol.yml" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/libraries/GOPATH__gache_.xml" afterPath="$PROJECT_DIR$/.idea/libraries/GOPATH__gache_.xml" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/docs/README.md" afterPath="$PROJECT_DIR$/docs/README.md" />
     </list>
     <ignored path="gache.iws" />
     <ignored path=".idea/workspace.xml" />
@@ -25,7 +23,18 @@
     <favorites_list name="gache" />
   </component>
   <component name="FileEditorManager">
-    <leaf />
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
+      <file leaf-file-name="protocol.yml" pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/docs/protocol.yml">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="557">
+              <caret line="159" column="55" selection-start-line="159" selection-start-column="55" selection-end-line="159" selection-end-column="55" />
+              <folding />
+            </state>
+          </provider>
+        </entry>
+      </file>
+    </leaf>
   </component>
   <component name="FileTemplateManagerImpl">
     <option name="RECENT_TEMPLATES">
@@ -54,13 +63,14 @@
         <option value="$PROJECT_DIR$/docs/runner_cli.md" />
         <option value="$PROJECT_DIR$/docs/README.md" />
         <option value="$PROJECT_DIR$/docs/runner_config.md" />
+        <option value="$PROJECT_DIR$/docs/protocol.yml" />
       </list>
     </option>
   </component>
   <component name="ProjectFrameBounds">
     <option name="y" value="23" />
-    <option name="width" value="1676" />
-    <option name="height" value="1027" />
+    <option name="width" value="1436" />
+    <option name="height" value="877" />
   </component>
   <component name="ProjectInspectionProfilesVisibleTreeState">
     <entry key="Project Default">
@@ -116,20 +126,7 @@
     </navigator>
     <panes>
       <pane id="Scratches" />
-      <pane id="Scope">
-        <subPane subId="Project Files">
-          <PATH>
-            <PATH_ELEMENT USER_OBJECT="Root">
-              <option name="myItemId" value="" />
-              <option name="myItemType" value="" />
-            </PATH_ELEMENT>
-            <PATH_ELEMENT USER_OBJECT="gache">
-              <option name="myItemId" value="" />
-              <option name="myItemType" value="" />
-            </PATH_ELEMENT>
-          </PATH>
-        </subPane>
-      </pane>
+      <pane id="PackagesPane" />
       <pane id="ProjectPane">
         <subPane>
           <PATH>
@@ -164,10 +161,23 @@
           </PATH>
         </subPane>
       </pane>
-      <pane id="PackagesPane" />
       <pane id="AndroidView">
         <subPane />
       </pane>
+      <pane id="Scope">
+        <subPane subId="Project Files">
+          <PATH>
+            <PATH_ELEMENT USER_OBJECT="Root">
+              <option name="myItemId" value="" />
+              <option name="myItemType" value="" />
+            </PATH_ELEMENT>
+            <PATH_ELEMENT USER_OBJECT="gache">
+              <option name="myItemId" value="" />
+              <option name="myItemType" value="" />
+            </PATH_ELEMENT>
+          </PATH>
+        </subPane>
+      </pane>
     </panes>
   </component>
   <component name="PropertiesComponent">
@@ -550,8 +560,8 @@
     <servers />
   </component>
   <component name="ToolWindowManager">
-    <frame x="0" y="23" width="1676" height="1027" extended-state="6" />
-    <editor active="false" />
+    <frame x="0" y="23" width="1436" height="877" extended-state="6" />
+    <editor active="true" />
     <layout>
       <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
       <window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
@@ -561,8 +571,8 @@
       <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
       <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
       <window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
-      <window_info id="Project" active="true" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2631265" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
-      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.13961814" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
+      <window_info id="Project" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.27044475" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
+      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.13916786" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
       <window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
       <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
       <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
@@ -600,6 +610,14 @@
     <watches-manager />
   </component>
   <component name="editorHistoryManager">
+    <entry file="file://$PROJECT_DIR$/docs/protocol.yml">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="0">
+          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
     <entry file="file://$PROJECT_DIR$/docs/components.md" />
     <entry file="file://$PROJECT_DIR$/hello.go" />
     <entry file="file://$PROJECT_DIR$/hello.go" />
@@ -635,7 +653,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="105">
             <caret line="7" column="0" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
-            <folding />
           </first_editor>
           <second_editor>
             <js_state />
@@ -646,7 +663,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="165">
             <caret line="11" column="12" selection-start-line="11" selection-start-column="12" selection-end-line="11" selection-end-column="12" />
-            <folding />
           </first_editor>
           <second_editor />
         </state>
@@ -658,7 +674,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="0">
             <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-            <folding />
           </first_editor>
           <second_editor>
             <js_state />
@@ -669,7 +684,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="30">
             <caret line="2" column="0" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
-            <folding />
           </first_editor>
           <second_editor />
         </state>
@@ -680,7 +694,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="0">
             <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-            <folding />
           </first_editor>
           <second_editor>
             <js_state />
@@ -691,7 +704,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="30">
             <caret line="2" column="25" selection-start-line="2" selection-start-column="25" selection-end-line="2" selection-end-column="25" />
-            <folding />
           </first_editor>
           <second_editor />
         </state>
@@ -702,7 +714,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="180">
             <caret line="12" column="33" selection-start-line="12" selection-start-column="33" selection-end-line="12" selection-end-column="33" />
-            <folding />
           </first_editor>
           <second_editor>
             <js_state />
@@ -715,7 +726,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="150">
             <caret line="10" column="47" selection-start-line="10" selection-start-column="47" selection-end-line="10" selection-end-column="47" />
-            <folding />
           </first_editor>
           <second_editor>
             <js_state />
@@ -726,7 +736,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="0">
             <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-            <folding />
           </first_editor>
           <second_editor />
         </state>
@@ -737,7 +746,6 @@
         <state split_layout="SPLIT">
           <first_editor relative-caret-position="369">
             <caret line="26" column="46" selection-start-line="26" selection-start-column="46" selection-end-line="26" selection-end-column="46" />
-            <folding />
           </first_editor>
           <second_editor>
             <js_state />
@@ -748,12 +756,19 @@
         <state split_layout="FIRST">
           <first_editor relative-caret-position="750">
             <caret line="50" column="2" selection-start-line="50" selection-start-column="2" selection-end-line="50" selection-end-column="2" />
-            <folding />
           </first_editor>
           <second_editor />
         </state>
       </provider>
     </entry>
+    <entry file="file://$PROJECT_DIR$/docs/protocol.yml">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="557">
+          <caret line="159" column="55" selection-start-line="159" selection-start-column="55" selection-end-line="159" selection-end-column="55" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
   </component>
   <component name="masterDetails">
     <states>

+ 169 - 0
docs/protocol.yml

@@ -0,0 +1,169 @@
+specification:
+  - https://github.com/memcached/memcached/blob/master/doc/protocol.txt
+  - Expiration times:
+    - Some commands involve a client sending some kind of expiration time (relative to an item or to
+      an operation requested by the client) to the server.
+    - In all such cases, the actual value sent may either be
+      - Unix time (number of seconds since January 1, 1970, as a 32-bit value),
+      - or a number of seconds starting from current time.
+    - In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30
+      days); if the number sent by a client is larger than that, the server will consider it to be
+      real Unix time value rather than an offset from current time.
+  - errors:
+    - "ERROR\r\n": means the client sent a nonexistent command name.
+    - "CLIENT_ERROR <error>\r\n": means some sort of client error in the input line, i.e. the input
+        doesn't conform to the protocol in some way. <error> is a  human-readable error string.
+    - "SERVER_ERROR <error>\r\n": means some sort of server error prevents the server from carrying
+        out the command. <error> is a human-readable error string. In cases of severe server errors,
+        which make it impossible to continue serving the client (this shouldn't normally happen),
+        the server will close the connection after sending the error line. This is the only case in
+        which the server closes a connection to a client.
+    - In the descriptions of individual commands below, these error lines are not again specifically
+      mentioned, but clients must allow for their possibility.
+
+commands:
+  - A command line always starts with the name of the command, followed by parameters (if any)
+    delimited by whitespace.
+  - Command names are lower-case and are case-sensitive.
+
+storage:
+  - ask the server to store some data identified by a key.
+  - The client sends a command line, and then a data block;
+  - After that the client expects one line of response, which will indicate success or failure.
+  - commands:
+    basic commands:
+      - "add|replace|set <key> <flags> <exptime> <bytes> [noreply]\r\n"
+      - add: store the data under the key, but only if data for the key does not already exist
+      - replace: store the data under the key, but only if data for the key already exist
+      - set: store the data under the key
+    update commands:
+      - "append|prepend <key> <bytes> [noreply]\r\n"
+      - append: add this data to an existing key after existing data (?)
+      - prepend: add this data to an existing key before existing data (?)
+    cas:
+      - "cas <key> <flags> <exptime> <bytes> <cas unique> [noreply]\r\n"
+      - check and set operation which means "store this data but only if no one else has updated
+        since I last fetched it."
+  - command format:
+    <key>: the key under which the client asks to store the data
+    <flags>: is an arbitrary 16-bit unsigned integer (written out in decimal) that the server stores
+      along with the data and sends back when the item is retrieved. Clients may use this as a bit
+      field to store data-specific information; this field is opaque to the server. Note that in
+      memcached 1.2.1 and higher, flags may be 32-bits, instead of 16, but you might want to
+      restrict yourself to 16 bits for compatibility with older versions.
+    <exptime>: is expiration time.:
+      - If it's 0, the item never expires (although it may be deleted from the cache to make place
+        for other items).
+      - If it's non-zero (either Unix time or offset in seconds from current time), it is guaranteed
+        that clients will not be able to retrieve this item after the expiration time arrives
+        (measured byserver time).
+      - If a negative value is given the item is immediately expired.
+    <bytes>:
+      - the number of bytes in the data block to follow, *not* including the delimiting \r\n.
+      - <bytes> may be zero (in which case it's followed by an empty data block).
+    <cas unique>:
+      - only used by the cas command
+      - a unique 64-bit value of an existing entry.
+      - Clients should use the value returned from the "gets" command when issuing "cas" updates.
+    "noreply":
+      - optional parameter instructs the server to not send the reply.
+      - NOTE: if the request line is malformed, the server can't parse "noreply" option reliably.
+        In this case it may send the error to the client, and not reading it on the client side will
+        break things.  Client should construct only valid requests.
+    data:
+      - After this line, the client sends the data block:
+      - <data block>\r\n
+      - <data block> is a chunk of arbitrary 8-bit data of length <bytes> from the previous line.
+  - responses:
+    - After sending the command line and the data block the client awaits the reply, which may be:
+      - "STORED\r\n", to indicate success.
+      - "NOT_STORED\r\n" to indicate the data was not stored, but not because of an error.
+        This normally means that the condition for an "add" or a "replace" command wasn't met.
+      - "EXISTS\r\n" to indicate that the item you are trying to store with a "cas" command has been
+        modified since you last fetched it.
+      - "NOT_FOUND\r\n" to indicate that the item you are trying to store with a "cas" command did
+        not exist.
+retrieval:
+  - ask the server to retrieve data corresponding to a set of keys (one or more keys in one
+    request).
+  - The client sends a command line, which includes all the requested keys;
+  - after that for each item the server finds it sends to the client one response line with
+    information about the item, and one data block with the item's data;
+  - this continues until the server finished with the "END" response line.
+  - commands:
+    - "get|gets <key>*\r\n"
+    - <key>* means one or more key strings separated by whitespace.
+    - After this command, the client expects zero or more items, each of which is received as a text
+      line followed by a data block. After all the items have been transmitted, the server sends the
+      string "END\r\n" to indicate the end of response.
+    - Each item sent by the server looks like this:
+      - VALUE <key> <flags> <bytes> [<cas unique>]\r\n
+      - <data block>\r\n
+      - <key> is the key for the item being sent
+      - <flags> is the flags value set by the storage command
+      - <bytes> is the length of the data block to follow, *not* including its delimiting \r\n
+      - <cas unique> is a unique 64-bit integer that uniquely identifies this specific item.
+      - <data block> is the data for this item.
+    - If some of the keys appearing in a retrieval request are not sent back by the server in the
+      item list this means that the server does not hold items with such keys (because they were
+      never stored, or stored but deleted to make space for more items, or expired, or explicitly
+      deleted by a client).
+other:
+  - don't involve unstructured data.
+  - In all of them, the client sends one command line, and expects (depending on the
+    command) either one line of response, or several lines of response ending with "END" on the last
+    line.
+  - commands:
+    - delete:
+      - "delete <key> [noreply]\r\n"
+      - <key> is the key of the item the client wishes the server to delete
+      - "noreply" optional parameter instructs the server to not send the reply.
+      - The response line to this command can be one of:
+        - "DELETED\r\n" to indicate success
+        - "NOT_FOUND\r\n" to indicate that the item with this key was not found.
+      - See the "flush_all" command below for immediate invalidation of all existing items.
+    - increment/decrement:
+      - change data for some item in-place, incrementing or decrementing it.
+      - "incr|decr <key> <value> [noreply]\r\n"
+      - <key> is the key of the item the client wishes to change
+      - <value> is the amount by which the client wants to increase/decrease the item. It is a
+        decimal representation of a 64-bit unsigned integer.
+      - "noreply" optional parameter instructs the server to not send the reply.
+      - The response will be one of:
+        - "NOT_FOUND\r\n" to indicate the item with this value was not found
+        - "<value>\r\n" , where <value> is the new value of the item's data, after the
+          increment/decrement operation was carried out.
+      - The data for the item is treated as decimal representation of a 64-bit unsigned integer.
+      - If the current data value does not conform to such a representation, the incr/decr commands
+        return an error
+      - The item must already exist for incr/decr to work; these commands won't pretend that a
+        non-existent key exists with value 0; instead, they will fail.
+      - Underflow in the "decr" command is caught: if a client tries to decrease the value below 0,
+        the new value will be 0.
+      - Overflow in the "incr" command will wrap around the 64 bit mark.
+      - Decrementing a number such that it loses length isn't guaranteed to decrement its returned
+        length.  The number MAY be space-padded at the end, but this is purely an implementation
+        optimization, so you also shouldn't rely on that.
+    - quit:
+    - touch:
+      - update the expiration time of an existing item without fetching it.
+      - "touch <key> <exptime> [noreply]\r\n"
+      - "<exptime>"
+        - Expiration time, same as with the storage commands (set/add/etc).
+        - This replaces the existing expiration time. If an existing item were to expire in 10
+          seconds, but then was touched with an expiration time of "20", the item would then expire
+          in 20 seconds.
+      - The response line to this command can be one of:
+        - "TOUCHED\r\n" to indicate success
+        - "NOT_FOUND\r\n" to indicate that the item with this key was not found.
+versions:
+  - Some notable changes... see Changelog for full list
+  - 2003 / 1.1.10: added flush_all command
+  - 2006 / 1.2.0: added UDP transport
+  - 2007 / 1.2.1: <flags> switched from a 16-bit value to a 32-bit value
+  - 2007 / 1.2.2: added verbosity command
+  - 2007 / 1.2.4:
+    - added cas and gets commands
+    - incr/decr values switched from 32-bit to 64-bit values
+  - 2009 / 1.2.7: increment/decrement no longer treats a non-integer value as 0 but returns an error
+  -