⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocol.txt

📁 memcached是一个高性能的分布式的内存对象缓存系统
💻 TXT
📖 第 1 页 / 共 2 页
字号:
  will also fail (the "set" command will succeed, however). After the  time passes, the item is finally deleted from server memory.  The parameter <time> is optional, and, if absent, defaults to 0  (which means that the item will be deleted immediately and further  storage commands with this key will succeed).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 invalidationof all existing items.Increment/Decrement-------------------Commands "incr" and "decr" are used to change data for some itemin-place, incrementing or decrementing it. The data for the item istreated as decimal representation of a 32-bit unsigned integer. If thecurrent data value does not conform to such a representation, thecommands behave as if the value were 0. Also, the item must alreadyexist for incr/decr to work; these commands won't pretend that anon-existent key exists with value 0; instead, they will fail.The client sends the command line:incr <key> <value>\r\nordecr <key> <value>\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/decreasethe item. It is a decimal representation of a 32-bit unsigned integer.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.Note that underflow in the "decr" command is caught: if a client triesto decrease the value below 0, the new value will be 0. Overflow inthe "incr" command is not checked.Note also that decrementing a number such that it loses length isn'tguaranteed to decrement its returned length.  The number MAY bespace-padded at the end, but this is purely an implementationoptimization, so you also shouldn't rely on that.Statistics----------The command "stats" is used to query the server about statistics itmaintains and other internal data. It has two forms. Withoutarguments:stats\r\nit causes the server to output general-purpose statistics andsettings, documented below.  In the other form it has some arguments:stats <args>\r\nDepending on <args>, various internal data is sent by the server. Thekinds of arguments and the data sent are not documented in this vesionof the protocol, and are subject to change for the convenience ofmemcache developers.General-purpose statistics--------------------------Upon receiving the "stats" command without arguments, the server sentsa number of lines which look like this:STAT <name> <value>\r\nThe server terminates this list with the lineEND\r\nIn each line of statistics, <name> is the name of this statistic, and<value> is the data.  The following is the list of all names sent inresponse to the "stats" command, together with the type of the valuesent for this name, and the meaning of the value.In the type column below, "32u" means a 32-bit unsigned integer, "64u"means a 64-bit unsigner integer. '32u:32u' means two 32-but unsignedintegers separated by a colon.Name              Type     Meaning----------------------------------pid               32u      Process id of this server processuptime            32u      Number of seconds this server has been runningtime              32u      current UNIX time according to the serverversion           string   Version string of this serverrusage_user       32u:32u  Accumulated user time for this process                            (seconds:microseconds)rusage_system     32u:32u  Accumulated system time for this process                            (seconds:microseconds)curr_items        32u      Current number of items stored by the servertotal_items       32u      Total number of items stored by this server                            ever since it startedbytes             64u      Current number of bytes used by this server                            to store itemscurr_connections  32u      Number of open connectionstotal_connections 32u      Total number of connections opened since                            the server started runningconnection_structures 32u  Number of connection structures allocated                            by the servercmd_get           64u      Cumulative number of retrieval requestscmd_set           64u      Cumulative number of storage requestsget_hits          64u      Number of keys that have been requested and                            found presentget_misses        64u      Number of items that have been requested                            and not foundevictions         64u      Number of items removed from cache because                           they passed their expiration timebytes_read        64u      Total number of bytes read by this server                            from networkbytes_written     64u      Total number of bytes sent by this server to                            networklimit_maxbytes    32u      Number of bytes this server is allowed to                           use for storage. Other commands--------------"flush_all" is a command with an optional numeric argument. It alwayssucceeds, and the server sends "OK\r\n" in response. Its effect is toinvalidate all existing items immediately (by default) or after theexpiration specified.  After invalidation none of the items will be returnedin response to a retrieval command (unless it's stored again under thesame key *after* flush_all has invalidated the items). flush_all doesn'tactually free all the memory taken up by existing items; that willhappen gradually as new items are stored. The most precise definitionof what flush_all does is the following: it causes all items whoseupdate time is earlier than the time at which flush_all was set to beexecuted to be ignored for retrieval purposes.The intent of flush_all with a delay, was that in a setting where youhave a pool of memcached servers, and you need to flush all content,you have the option of not resetting all memcached servers at thesame time (which could e.g. cause a spike in database load with allclients suddenly needing to recreate content that would otherwisehave been found in the memcached daemon).The delay option allows you to have them reset in e.g. 10 secondintervals (by passing 0 to the first, 10 to the second, 20 to thethird, etc. etc.)."version" is a command with no arguments:version\r\nIn response, the server sends"VERSION <version>\r\n", where <version> is the version string for theserver."verbosity" is a command with a numeric argument. It always                                                  succeeds, and the server sends "OK\r\n" in response. Its effect is to                                        set the verbosity level of the logging output.                                                               "quit" is a command with no arguments:quit\r\nUpon receiving this command, the server closes theconnection. However, the client may also simply close the connectionwhen it no longer needs it, without issuing this command.UDP protocol------------For very large installations where the number of clients is high enoughthat the number of TCP connections causes scaling difficulties, there isalso a UDP-based interface. The UDP interface does not provide guaranteeddelivery, so should only be used for operations that aren't required tosucceed; typically it is used for "get" requests where a missing orincomplete response can simply be treated as a cache miss.Each UDP datagram contains a simple frame header, followed by data in thesame format as the TCP protocol described above. In the currentimplementation, requests must be contained in a single UDP datagram, butresponses may span several datagrams. (The only common requests that wouldspan multiple datagrams are huge multi-key "get" requests and "set"requests, both of which are more suitable to TCP transport for reliabilityreasons anyway.)The frame header is 8 bytes long, as follows (all values are 16-bit integersin network byte order, high byte first):0-1 Request ID2-3 Sequence number4-5 Total number of datagrams in this message6-7 Reserved for future use; must be 0The request ID is supplied by the client. Typically it will be amonotonically increasing value starting from a random seed, but the clientis free to use whatever request IDs it likes. The server's response willcontain the same ID as the incoming request. The client uses the request IDto differentiate between responses to outstanding requests if there areseveral pending from the same server; any datagrams with an unknown requestID are probably delayed responses to an earlier request and should bediscarded.The sequence number ranges from 0 to n-1, where n is the total number ofdatagrams in the message. The client should concatenate the payloads of thedatagrams for a given response in sequence number order; the resulting bytestream will contain a complete response in the same format as the TCPprotocol (including terminating \r\n sequences).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -