Show
Ignore:
Timestamp:
10/03/07 19:59:11 (2 years ago)
Author:
plindner
Message:

Incorporate "cas" operation developed by Dustin Sallings
<dustin@…> and implemented by Chris Goffinet
<goffinet@…>. This change allows you to do
atomic changes to an existing key.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/server/doc/protocol.txt

    r609 r615  
    5454There are three types of commands.  
    5555 
    56 Storage commands (there are three: "set", "add" and "replace") ask the 
    57 server to store some data identified by a key. The client sends a 
    58 command line, and then a data block; after that the client expects one 
    59 line of response, which will indicate success or faulure. 
    60  
    61 Retrieval commands (there is only one: "get") ask the server to 
     56Storage commands (there are four: "set", "add", "replace", and "cas") 
     57ask the server to store some data identified by a key. The client 
     58sends a command line, and then a data block; after that the client 
     59expects one line of response, which will indicate success or faulure. 
     60 
     61Retrieval commands (there are two: "get" and "gets") ask the server to 
    6262retrieve data corresponding to a set of keys (one or more keys in one 
    6363request). The client sends a command line, which includes all the 
     
    126126First, the client sends a command line which looks like this: 
    127127 
    128 <command name> <key> <flags> <exptime> <bytes>\r\n 
    129  
    130 - <command name> is "set", "add" or "replace" 
     128<command name> <key> <flags> <exptime> <bytes> [<unqiue>]\r\n 
     129 
     130- <command name> is "set", "add", "replace", or "cas" 
    131131 
    132132  "set" means "store this data".   
     
    137137  "replace" means "store this data, but only if the server *does* 
    138138  already hold data for this key". 
     139 
     140  "cas" is a check and set operation which means "store this data but 
     141  only if no one else has updated since I last fetched it." 
    139142 
    140143- <key> is the key under which the client asks to store the data 
     
    159162  it's followed by an empty data block). 
    160163 
     164- <cas unique> is a unique 64-bit value of an existing entry. 
     165 
    161166After this line, the client sends the data block: 
    162167 
     
    176181item is in a delete queue (see the "delete" command below). 
    177182 
     183- "EXISTS\r\n" to indicate that the item you are trying to store with 
     184a "cas" command has been modified since you last fetched it. 
    178185 
    179186Retrieval command: 
    180187------------------ 
    181188 
    182 The retrieval command looks like this: 
     189The retrieval commands "get" and "gets" operates like this: 
    183190 
    184191get <key>*\r\n 
     192gets <key>*\r\n 
    185193 
    186194- <key>* means one or more key strings separated by whitespace. 
     
    196204Each item sent by the server looks like this: 
    197205 
    198 VALUE <key> <flags> <bytes>\r\n 
     206VALUE <key> <flags> <bytes> [<cas unique>]\r\n 
    199207<data block>\r\n 
    200208 
     
    205213- <bytes> is the length of the data block to follow, *not* including 
    206214  its delimiting \r\n 
     215 
     216- <cas unique> is a unique 64-bit integer that uniquely identifies 
     217  this specific item. 
    207218 
    208219- <data block> is the data for this item. 
     
    213224but deleted to make space for more items, or expired, or explicitly 
    214225deleted by a client). 
    215  
    216226 
    217227