• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴(yán)以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            memcached協(xié)議

            轉(zhuǎn)載自:http://www.blogjava.net/czihong/articles/373216.html

            在memcache協(xié)議中發(fā)送的數(shù)據(jù)分兩種:文本行 和 自由數(shù)據(jù)。 文本行被用于來自客戶端的命令和服務(wù)器的回應(yīng)。自由數(shù)據(jù)用于客戶端從服務(wù)器端存取數(shù)據(jù)時(shí)。存儲(chǔ)在memcached中的數(shù)據(jù)通過鍵值來標(biāo)識(shí)。鍵值是一個(gè)文本字符串,對(duì)于需要存取這項(xiàng)數(shù)據(jù)的客戶端而言,它必須是唯一的。

            協(xié)議
            Protocol
            memcached 的客戶端使用TCP鏈接 與 服務(wù)器通訊。(UDP接口也同樣有效,參考后文的 “UDP協(xié)議” )一個(gè)運(yùn)行中的memcached服務(wù)器監(jiān)視一些(可設(shè)置)端口。客戶端連接這些端口,發(fā)送命令到服務(wù)器,讀取回應(yīng),最后關(guān)閉連接。 Clients of memcached communicate with server through TCP connections. (A UDP interface is also available; details are below under “UDP protocol.”) A given running memcached server listens on some (configurable) port; clients connect to that port, send commands to the server, read responses, and eventually close the connection.
            結(jié)束會(huì)話不需要發(fā)送任何命令。當(dāng)不再需memcached服務(wù)時(shí),要客戶端可以在任何時(shí)候關(guān)閉連接。需要注意的是,鼓勵(lì)客戶端緩存這些連接,而不是每次需要存取數(shù)據(jù)時(shí)都重新打開連接。這是因?yàn)閙emcached 被特意設(shè)計(jì)成及時(shí)開啟很多連接也能夠高效的工作(數(shù)百個(gè),上千個(gè)如果需要的話)。緩存這些連接,可以消除建立連接所帶來的開銷(/*/相對(duì)而言,在服務(wù)器端建立一個(gè)新連接的準(zhǔn)備工作所帶來的開銷,可以忽略不計(jì)。)。 There is no need to send any command to end the session. A client may just close the connection at any moment it no longer needs it. Note, however, that clients are encouraged to cache their connections rather than reopen them every time they need to store or retrieve data. This is because memcached is especially designed to work very efficiently with a very large number (many hundreds, more than a thousand if necessary) of open connections. Caching connections will eliminate the overhead associated with establishing a TCP connection (the overhead of preparing for a new connection on the server side is insignificant compared to this).
            在memcache協(xié)議中發(fā)送的數(shù)據(jù)分兩種:文本行 和 自由數(shù)據(jù)。 文本行被用于來自客戶端的命令和服務(wù)器的回應(yīng)。自由數(shù)據(jù)用于客戶端從服務(wù)器端存取數(shù)據(jù)時(shí)。同樣服務(wù)器會(huì)以字節(jié)流的方式傳回自由數(shù)據(jù)。/*/服務(wù)器不用關(guān)心自由數(shù)據(jù)的字節(jié)順序。自由數(shù)據(jù)的特征沒有任何限制;但是通過前文提到的文本行,這項(xiàng)數(shù)據(jù)的接受者(服務(wù)器或客戶端),便能夠精確地獲知所發(fā)送的數(shù)據(jù)庫(kù)的長(zhǎng)度。 There are two kinds of data sent in the memcache protocol: text lines
            and unstructured data. Text lines are used for commands from clients
            and responses from servers. Unstructured data is sent when a client
            wants to store or retrieve data. The server will transmit back
            unstructured data in exactly the same way it received it, as a byte
            stream. The server doesn’t care about byte order issues in
            unstructured data and isn’t aware of them. There are no limitations on
            characters that may appear in unstructured data; however, the reader
            of such data (either a client or a server) will always know, from a
            preceding text line, the exact length of the data block being
            transmitted.
            文本行固定以“\r\n”(回車符緊跟一個(gè)換行符)結(jié)束。 自由數(shù)據(jù)也是同樣會(huì)以“\r\n”結(jié)束,但是 \r(回車符)、\n(換行符),以及任何其他8位字符,均可出現(xiàn)在數(shù)據(jù)中。因此,當(dāng)客戶端從服務(wù)器取回?cái)?shù)據(jù)時(shí),必須使用數(shù)據(jù)區(qū)塊的長(zhǎng)度來確定數(shù)據(jù)區(qū)塊的結(jié)束位置,而不要依據(jù)數(shù)據(jù)區(qū)塊末尾的“\r\n”,即使它們固定存在于此。 Text lines are always terminated by \r\n. Unstructured data is _also_
            terminated by \r\n, even though \r, \n or any other 8-bit characters
            may also appear inside the data. Therefore, when a client retrieves
            data from a server, it must use the length of the data block (which it
            will be provided with) to determine where the data block ends, and not
            the fact that \r\n follows the end of the data block, even though it
            does.
               
            鍵值
            Keys
            存儲(chǔ)在memcached中的數(shù)據(jù)通過鍵值來標(biāo)識(shí)。鍵值是一個(gè)文本字符串,對(duì)于需要存取這項(xiàng)數(shù)據(jù)的客戶端而言,它必須是唯一的。鍵值當(dāng)前的長(zhǎng)度限制設(shè)定為250字符(當(dāng)然,客戶端通常不會(huì)用到這么長(zhǎng)的鍵);鍵值中不能使用制表符和其他空白字符(例如空格,換行等)。 Data stored by memcached is identified with the help of a key. A key
            is a text string which should uniquely identify the data for clients
            that are interested in storing and retrieving it. Currently the
            length limit of a key is set at 250 characters (of course, normally
            clients wouldn’t need to use such long keys); the key must not include
            control characters or whitespace.
               
            命令
            Commands
            所有命令分為3種類型 There are three types of commands.
            存儲(chǔ)命令(有3項(xiàng):’set’、’add’、’repalce’)指示服務(wù)器儲(chǔ)存一些由鍵值標(biāo)識(shí)的數(shù)據(jù)。客戶端發(fā)送一行命令,后面跟著數(shù)據(jù)區(qū)塊;然后,客戶端等待接收服務(wù)器回傳的命令行,指示成功與否。 Storage commands (there are three: “set”, “add” and “replace”) 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 faulure.
            取回命令(只有一項(xiàng):’get’)指示服務(wù)器返回與所給鍵值相符合的數(shù)據(jù)(一個(gè)請(qǐng)求中右一個(gè)或多個(gè)鍵值)。客戶端發(fā)送一行命令,包括所有請(qǐng)求的鍵值;服務(wù)器每找到一項(xiàng)內(nèi)容,都會(huì)發(fā)送回客戶端一行關(guān)于這項(xiàng)內(nèi)容的信息,緊跟著是對(duì)應(yīng)的數(shù)據(jù)區(qū)塊;直到服務(wù)器以一行“END”回應(yīng)命令結(jié)束。 Retrieval commands (there is only one: “get”) 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.
            /*?*/其他的命令都不能攜帶自由數(shù)據(jù)。在這些命令中,客戶端發(fā)送一行命令,然后等待(由命令所決定)一行回應(yīng),或最終以一行“END”結(jié)束的多行命令。 All other commands 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.
            一行命令固定以命令名稱開始,接著是以空格隔開的參數(shù)(如果有參數(shù)的話)。命令名稱大小寫敏感,并且必須小寫。 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.
               
            一些客戶端發(fā)送給服務(wù)器的命令會(huì)包含一些時(shí)限(針對(duì)內(nèi)容或客戶端請(qǐng)求的操作)。這時(shí),時(shí)限的具體內(nèi)容既可以是Unix時(shí)間戳(從1970年1月1日開始的秒鐘數(shù)),或當(dāng)前時(shí)間開始的秒鐘數(shù)。對(duì)后者而言,不能超過 60*60*24*30(30天);如果超出,服務(wù)器將會(huì)理解為Unix時(shí)間戳,而不是從當(dāng)前時(shí)間起的秒偏移。 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.
               
            錯(cuò)誤字串
            Error strings
            每一個(gè)由客戶端發(fā)送的命令,都可能收到來自服務(wù)器的錯(cuò)誤字串回復(fù)。這些錯(cuò)誤字串會(huì)以三種形式出現(xiàn): Each command sent by a client may be answered with an error string
            from the server. These error strings come in three types:
            - “ERROR\r\n”
            意味著客戶端發(fā)送了不存在的命令名稱。 means the client sent a nonexistent command name.
            - “CLIENT_ERROR <error>\r\n”
            意味著輸入的命令行里存在一些客戶端錯(cuò)誤,例如輸入未遵循協(xié)議。<error>部分是人類易于理解的錯(cuò)誤解說…… 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”
            意味著一些服務(wù)器錯(cuò)誤,導(dǎo)致命令無法執(zhí)行。<error>部分是人類易于理解的錯(cuò)誤解說。在一些嚴(yán)重的情形下(通常應(yīng)該不會(huì)遇到),服務(wù)器將在發(fā)送這行錯(cuò)誤后關(guān)閉連接。這是服務(wù)器主動(dòng)關(guā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.
            在后面每項(xiàng)命令的描述中,這些錯(cuò)誤行不會(huì)再特別提到,但是客戶端必須考慮到這些它們存在的可能性。 In the descriptions of individual commands below, these error lines
            are not again specifically mentioned, but clients must allow for their
            possibility.
               
            存儲(chǔ)命令
            Storage commands
            首先,客戶端會(huì)發(fā)送一行像這樣的命令: First, the client sends a command line which looks like this:
            <command name> <key> <flags> <exptime> <bytes>\r\n
            - <command name> 是 set, add, 或者 repalce - <command name> is “set”, “add” or “replace”
            • set 意思是 “儲(chǔ)存此數(shù)據(jù)”
            • add 意思是 “儲(chǔ)存此數(shù)據(jù),只在服務(wù)器*未*保留此鍵值的數(shù)據(jù)時(shí)”
            • replace意思是 “儲(chǔ)存此數(shù)據(jù),只在服務(wù)器*曾*保留此鍵值的數(shù)據(jù)時(shí)”
            • “set” means “store this data”.
            • “add” means “store this data, but only if the server *doesn’t* already
              hold data for this key”.
            • “replace” means “store this data, but only if the server *does*
              already hold data for this key”.
            - <key> 是接下來的客戶端所要求儲(chǔ)存的數(shù)據(jù)的鍵值 - <key> is the key under which the client asks to store the data
            - <flags> 是在取回內(nèi)容時(shí),與數(shù)據(jù)和發(fā)送塊一同保存服務(wù)器上的任意16位無符號(hào)整形(用十進(jìn)制來書寫)。客戶端可以用它作為“位域”來存儲(chǔ)一些特定的信息;它對(duì)服務(wù)器是不透明的。 - <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.
            - <exptime> 是終止時(shí)間。如果為0,該項(xiàng)永不過期(雖然它可能被刪除,以便為其他緩存項(xiàng)目騰出位置)。如果非0(Unix時(shí)間戳或當(dāng)前時(shí)刻的秒偏移),到達(dá)終止時(shí)間后,客戶端無法再獲得這項(xiàng)內(nèi)容。 - <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 by
            server time).
            - <bytes> 是隨后的數(shù)據(jù)區(qū)塊的字節(jié)長(zhǎng)度,不包括用于分野的“\r\n”。它可以是0(這時(shí)后面跟隨一個(gè)空的數(shù)據(jù)區(qū)塊)。 - <bytes> is 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).
               
            在這一行以后,客戶端發(fā)送數(shù)據(jù)區(qū)塊。 After this line, the client sends the data block:
            <data block>\r\n
            - <data block> 是大段的8位數(shù)據(jù),其長(zhǎng)度由前面的命令行中的<bytes>指定。 - <data block> is a chunk of arbitrary 8-bit data of length <bytes>
            from the previous line.
            發(fā)送命令行和數(shù)據(jù)區(qū)塊以后,客戶端等待回復(fù),可能的回復(fù)如下: After sending the command line and the data blockm the client awaits
            the reply, which may be:
            - “STORED\r\n”
            表明成功. to indicate success.
            - “NOT_STORED\r\n”
            表明數(shù)據(jù)沒有被存儲(chǔ),但不是因?yàn)榘l(fā)生錯(cuò)誤。這通常意味著add 或 replace命令的條件不成立,或者,項(xiàng)目已經(jīng)位列刪除隊(duì)列(參考后文的“delete”命令)。 to indicate the data was not stored, but not
            because of an error. This normally means that either that the
            condition for an “add” or a “replace” command wasn’t met, or that the
            item is in a delete queue (see the “delete” command below).
               
            取回命令
            Retrieval command
            一行取回命令如下: The retrieval command looks like this:
            get <key>*\r\n
            - <key>* 表示一個(gè)或多個(gè)鍵值,由空格隔開的字串 - <key>* means one or more key strings separated by whitespace.
            這行命令以后,客戶端的等待0個(gè)或多個(gè)項(xiàng)目,每項(xiàng)都會(huì)收到一行文本,然后跟著數(shù)據(jù)區(qū)塊。所有項(xiàng)目傳送完畢后,服務(wù)器發(fā)送以下字串: 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”
            來指示回應(yīng)完畢。 to indicate the end of response.
            服務(wù)器用以下形式發(fā)送每項(xiàng)內(nèi)容: Each item sent by the server looks like this:
            VALUE <key> <flags> <bytes>\r\n
            <data block>\r\n
            - <key> 是所發(fā)送的鍵名 - <key> is the key for the item being sent
            - <flags> 是存儲(chǔ)命令所設(shè)置的記號(hào) - <flags> is the flags value set by the storage command
            - <bytes> 是隨后數(shù)據(jù)塊的長(zhǎng)度,*不包括* 它的界定符“\r\n” - <bytes> is the length of the data block to follow, *not* including
            its delimiting \r\n
            - <data block> 是發(fā)送的數(shù)據(jù) - <data block> is the data for this item.
            如果在取回請(qǐng)求中發(fā)送了一些鍵名,而服務(wù)器沒有送回項(xiàng)目列表,這意味著服務(wù)器沒這些鍵名(可能因?yàn)樗鼈儚奈幢淮鎯?chǔ),或者為給其他內(nèi)容騰出空間而被刪除,或者到期,或者被已客戶端刪除)。 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).
               
            刪除
            Deletion
            命令“delete”允許從外部刪除內(nèi)容: The command “delete” allows for explicit deletion of items:
            delete <key> <time>\r\n
            - <key> 是客戶端希望服務(wù)器刪除的內(nèi)容的鍵名 - <key> is the key of the item the client wishes the server to delete
            - <time> 是一個(gè)單位為秒的時(shí)間(或代表直到某一刻的Unix時(shí)間),在該時(shí)間內(nèi)服務(wù)器會(huì)拒絕對(duì)于此鍵名的“add”和“replace”命令。此時(shí)內(nèi)容被放入delete隊(duì)列,無法再通過“get”得到該內(nèi)容,也無法是用“add”和“replace”命令(但是“set”命令可用)。直到指定時(shí)間,這些內(nèi)容被最終從服務(wù)器的內(nèi)存中徹底清除。 - <time> is the amount of time in seconds (or Unix time until which)
            the client wishes the server to refuse “add” and “replace” commands
            with this key. For this amount of item, the item is put into a
            delete queue, which means that it won’t possible to retrieve it by
            the “get” command, but “add” and “replace” command with this key
            will also fail (the “set” command will succeed, however). After the
            time passes, the item is finally deleted from server memory.
            <time>參數(shù) 是可選的,缺省為0(表示內(nèi)容會(huì)立刻清除,并且隨后的存儲(chǔ)命令均可用)。 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).
            此命令有一行回應(yīng): The response line to this command can be one of:
            - “DELETED\r\n”
            表示執(zhí)行成功 to indicate success
            - “NOT_FOUND\r\n”
            表示沒有找到這項(xiàng)內(nèi)容 to indicate that the item with this key was not found.
            參考隨后的“flush_all”命令使所有內(nèi)容無效 See the “flush_all” command below for immediate invalidation
            of all existing items.
               
            增加/減少
            Increment/Decrement
            命令 “incr” 和 “decr”被用來修改數(shù)據(jù),當(dāng)一些內(nèi)容需要 替換、增加 或減少時(shí)。這些數(shù)據(jù)必須是十進(jìn)制的32位無符號(hào)整新。如果不是,則當(dāng)作0來處理。修改的內(nèi)容必須存在,當(dāng)使用“incr”/“decr”命令修改不存在的內(nèi)容時(shí),不會(huì)被當(dāng)作0處理,而是操作失敗。 Commands “incr” and “decr” are used to change data for some item
            in-place, incrementing or decrementing it. The data for the item is
            treated as decimal representation of a 32-bit unsigned integer. If the
            current data value does not conform to such a representation, the
            commands behave as if the value were 0. Also, 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.
            客戶端發(fā)送命令行: The client sends the command line:
            incr <key> <value>\r\n

            decr <key> <value>\r\n
            - <key> 是客戶端希望修改的內(nèi)容的建名 - <key> is the key of the item the client wishes to change
            - <value> 是客戶端要增加/減少的總數(shù)。 - <value> is the amount by which the client wants to increase/decrease
            the item. It is a decimal representation of a 32-bit unsigned integer.
            回復(fù)為以下集中情形: The response will be one of:
            - “NOT_FOUND\r\n”
            指示該項(xiàng)內(nèi)容的值,不存在。 to indicate the item with this value was not found
            - <value>\r\n ,<value>是 增加/減少 。 - <value>\r\n , where <value> is the new value of the item’s data,
            after the increment/decrement operation was carried out.
            注意”decr”命令發(fā)生下溢:如果客戶端嘗試減少的結(jié)果小于0時(shí),結(jié)果會(huì)是0。”incr” 命令不會(huì)發(fā)生溢出。 Note that 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 is not checked.
            ……

             

            Note also that 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.
               
            狀態(tài)
            Statistics
            命令”stats” 被用于查詢服務(wù)器的運(yùn)行狀態(tài)和其他內(nèi)部數(shù)據(jù)。有兩種格式。不帶參數(shù)的: The command “stats” is used to query the server about statistics it
            maintains and other internal data. It has two forms. Without
            arguments:
             stats\r\n
            這會(huì)在隨后輸出各項(xiàng)狀態(tài)、設(shè)定值和文檔。另一種格式帶有一些參數(shù): it causes the server to output general-purpose statistics and
            settings, documented below. In the other form it has some arguments:
            stats <args>\r\n
            通過<args>,服務(wù)器傳回各種內(nèi)部數(shù)據(jù)。因?yàn)殡S時(shí)可能發(fā)生變動(dòng),本文不提供參數(shù)的種類及其傳回?cái)?shù)據(jù)。 Depending on <args>, various internal data is sent by the server. The
            kinds of arguments and the data sent are not documented in this vesion
            of the protocol, and are subject to change for the convenience of
            memcache developers.
               
            各種狀態(tài)
            General-purpose statistics
            受到無參數(shù)的”stats”命令后,服務(wù)器發(fā)送多行內(nèi)容,如下: Upon receiving the “stats” command without arguments, the server sents
            a number of lines which look like this:
            STAT <name> <value>\r\n
            服務(wù)器用以下一行來終止這個(gè)清單: The server terminates this list with the line
            END\r\n
            在每行狀態(tài)中,<name> 是狀態(tài)的名字,<value> 使?fàn)顟B(tài)的數(shù)據(jù)。 以下清單,是所有的狀態(tài)名稱,數(shù)據(jù)類型,和數(shù)據(jù)代表的含義。 In 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 in
            response to the “stats” command, together with the type of the value
            sent for this name, and the meaning of the value.
            在“類型”一列中,”32u”表示32位無符號(hào)整型,”64u”表示64位無符號(hào)整型,”32u:32u”表示用冒號(hào)隔開的兩個(gè)32位無符號(hào)整型。 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 unsigned
            integers separated by a colon.
            名稱/Name 類型/Type 含義/Meaning
            pid 32u 服務(wù)器進(jìn)程ID Process id of this server process
            uptime 32u 服務(wù)器運(yùn)行時(shí)間,單位秒 Number of seconds this server has been running
            time 32u 服務(wù)器當(dāng)前的UNIX時(shí)間 current UNIX time according to the server
            version string 服務(wù)器的版本號(hào) Version string of this server
            rusage_user 32u:32u 該進(jìn)程累計(jì)的用戶時(shí)間
            (秒:微妙)
            Accumulated user time for this process
            (seconds:microseconds)
            rusage_system 32u:32u 該進(jìn)程累計(jì)的系統(tǒng)時(shí)間
            (秒:微妙)
            Accumulated system time for this process
            (seconds:microseconds)
            curr_items 32u 服務(wù)器當(dāng)前存儲(chǔ)的內(nèi)容數(shù)量 Current number of items stored by the server
            total_items 32u 服務(wù)器啟動(dòng)以來存儲(chǔ)過的內(nèi)容總數(shù) Total number of items stored by this server
            ever since it started
            bytes 64u 服務(wù)器當(dāng)前存儲(chǔ)內(nèi)容所占用的字節(jié)數(shù) Current number of bytes used by this server
            to store items
            curr_connections 32u 連接數(shù)量 Number of open connections
            total_connections 32u 服務(wù)器運(yùn)行以來接受的連接總數(shù) Total number of connections opened since
            the server started running
            connection_structures 32u 服務(wù)器分配的連接結(jié)構(gòu)的數(shù)量 Number of connection structures allocated
            by the server
            cmd_get 32u 取回請(qǐng)求總數(shù) Cumulative number of retrieval requests
            cmd_set 32u 存儲(chǔ)請(qǐng)求總數(shù) Cumulative number of storage requests
            get_hits 32u 請(qǐng)求成功的總次數(shù) Number of keys that have been requested and
            found present
            get_misses 32u 請(qǐng)求失敗的總次數(shù) Number of items that have been requested
            and not found
            bytes_read 64u 服務(wù)器從網(wǎng)絡(luò)讀取到的總字節(jié)數(shù) Total number of bytes read by this server
            from network
            bytes_written 64u 服務(wù)器向網(wǎng)絡(luò)發(fā)送的總字節(jié)數(shù) Total number of bytes sent by this server to
            network
            limit_maxbytes 32u 服務(wù)器在存儲(chǔ)時(shí)被允許使用的字節(jié)總數(shù) Number of bytes this server is allowed to
            use for storage.
               
            其它命令
            Other commands
            “flush_all”命令有一個(gè)可選的數(shù)字參數(shù)。它總是執(zhí)行成功,服務(wù)器會(huì)發(fā)送“OK\r\n”回應(yīng)。它的效果是使已經(jīng)存在的項(xiàng)目立即失效(缺省),或在指定的時(shí)間后。此后執(zhí)行取回命令,將不會(huì)有任何內(nèi)容返回(除非重新存儲(chǔ)同樣的鍵名)。flush_all 實(shí)際上沒有立即釋放項(xiàng)目所占用的內(nèi)存,而是在隨后陸續(xù)有新的項(xiàng)目被儲(chǔ)存時(shí)執(zhí)行。flush_all 效果具體如下:它導(dǎo)致所有更新時(shí)間早于flush_all所設(shè)定時(shí)間的項(xiàng)目,在被執(zhí)行取回命令時(shí)命令被忽略。 “flush_all” is a command with an optional numeric argument. It always succeeds, and the server sends “OK\r\n” in response. Its effect is to invalidate all existing items immediately (by default) or after the expiration specified. After invalidation none of the items will be returned in response to a retrieval command (unless it’s stored again under the same key *after* flush_all has invalidated the items). flush_all doesn’t actually free all the memory taken up by existing items; that will happen gradually as new items are stored. The most precise definition of what flush_all does is the following: it causes all items whose update time is earlier than the time at which flush_all was set to be executed to be ignored for retrieval purposes.
            “version”命令沒有參數(shù): “version” is a command with no arguments:
            version\r\n
            在回應(yīng)中,服務(wù)器發(fā)送: In response, the server sends
            “VERSION <version>\r\n”
            <version> 是服務(wù)器的版本字串。 where <version> is the version string for the server.
            “quit”命令沒有參數(shù): “quit” is a command with no arguments:
            quit\r\n
            接收此命令后,服務(wù)器關(guān)閉連接。不過,客戶端可以在不再需要時(shí),簡(jiǎn)單地關(guān)閉連接就行,并不一定需要發(fā)送這個(gè)命令。 Upon receiving this command, the server closes the connection. However, the client may also simply close the connection when it no longer needs it, without issuing this command.
               
            UDP 協(xié)議
            UDP protocol
            當(dāng)來自客戶端的連接數(shù)遠(yuǎn)大于TCP連接的上限時(shí),可以使用基于UDP的接口。UDP接口不能保證傳輸?shù)轿唬灾挥性诓灰蟪晒Φ牟僮髦惺褂茫槐热绫挥糜谝粋€(gè)“get”請(qǐng)求時(shí),會(huì)因不當(dāng)?shù)木彺嫣幚矶l(fā)生錯(cuò)誤或回應(yīng)有遺失。 For very large installations where the number of clients is high enough that the number of TCP connections causes scaling difficulties, there is also a UDP-based interface. The UDP interface does not provide guaranteed delivery, so should only be used for operations that aren’t required to succeed; typically it is used for “get” requests where a missing or incomplete response can simply be treated as a cache miss.
            每個(gè)UDP數(shù)據(jù)包都包含一個(gè)簡(jiǎn)單的幀頭,數(shù)據(jù)之后的內(nèi)容與TCP協(xié)議的描述類似。在執(zhí)行所產(chǎn)生的數(shù)據(jù)流中,請(qǐng)求必須被包含在單獨(dú)的一個(gè)UDP數(shù)據(jù)包中,但是回應(yīng)可能跨越多個(gè)數(shù)據(jù)包。(只有“get”和“set”請(qǐng)求例外,跨越了多個(gè)數(shù)據(jù)包) Each UDP datagram contains a simple frame header, followed by data in the same format as the TCP protocol described above. In the current implementation, requests must be contained in a single UDP datagram, but responses may span several datagrams. (The only common requests that would span multiple datagrams are huge multi-key “get” requests and “set” requests, both of which are more suitable to TCP transport for reliability reasons anyway.)
            幀頭有8字節(jié)長(zhǎng),如下(均由16位整數(shù)組成,網(wǎng)絡(luò)字節(jié)順序,高位在前): The frame header is 8 bytes long, as follows (all values are 16-bit integers in network byte order, high byte first):
            • 0-1 請(qǐng)求ID
            • 2-3 序號(hào)
            • 4-5 該信息的數(shù)據(jù)包總數(shù)
            • 6-7 保留位,必須為0
            • 0-1 Request ID
            • 2-3 Sequence number
            • 4-5 Total number of datagrams in this message
            • 6-7 Reserved for future use; must be 0
            請(qǐng)求ID有客戶端提供。一般它會(huì)是一個(gè)從隨機(jī)基數(shù)開始的遞增值,不過客戶端想用什么樣的請(qǐng)求ID都可以。服務(wù)器的回應(yīng)會(huì)包含一個(gè)和請(qǐng)求中的同樣的ID。客戶端使用請(qǐng)求ID來區(qū)分每一個(gè)回應(yīng)。任何一個(gè)沒有請(qǐng)求ID的數(shù)據(jù)包,可能是之前的請(qǐng)求遭到延遲而造成的,應(yīng)該被丟棄。 The request ID is supplied by the client. Typically it will be a monotonically increasing value starting from a random seed, but the client is free to use whatever request IDs it likes. The server’s response will contain the same ID as the incoming request. The client uses the request ID to differentiate between responses to outstanding requests if there are several pending from the same server; any datagrams with an unknown request ID are probably delayed responses to an earlier request and should be discarded.
            序號(hào)的返回是從0到n-1,n是該條信息的數(shù)據(jù)包數(shù)量。 The sequence number ranges from 0 to n-1, where n is the total number of datagrams in the message. The client should concatenate the payloads of the datagrams for a given response in sequence number order; the resulting byte stream will contain a complete response in the same format as the TCP protocol (including terminating \r\n sequences).


            -----------------------------------------------------
            Silence, the way to avoid many problems;
            Smile, the way to solve many problems;

            posted on 2014-06-17 14:34 楊粼波 閱讀(988) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久九色综合九色99伊人| 国产精品久久久久a影院| 久久综合亚洲欧美成人| 久久国产精品久久国产精品| 精品水蜜桃久久久久久久| 久久久久久久综合狠狠综合| 2020久久精品国产免费| 久久综合亚洲色HEZYO国产| 亚洲中文字幕无码久久综合网 | 久久亚洲精品无码aⅴ大香| 无码日韩人妻精品久久蜜桃| 91精品国产91久久久久久| 亚洲AV成人无码久久精品老人| 精品一区二区久久| 亚洲欧美伊人久久综合一区二区| 精品久久久久久久中文字幕| 99久久精品费精品国产一区二区| 久久综合色老色| 久久久久久毛片免费看| 大伊人青草狠狠久久| 97精品依人久久久大香线蕉97 | 亚洲国产成人精品91久久久 | 狠狠色噜噜色狠狠狠综合久久| 中文字幕久久欲求不满| 99久久国语露脸精品国产| 久久精品国产亚洲av日韩| 亚洲欧洲日产国码无码久久99| 性做久久久久久久久久久| 久久久久人妻精品一区三寸蜜桃| 国产精品美女久久久m| 色婷婷久久综合中文久久蜜桃av| 色婷婷久久综合中文久久一本| 九九久久精品无码专区| 国产AV影片久久久久久 | 麻豆精品久久久久久久99蜜桃| 热综合一本伊人久久精品| 人妻少妇精品久久| 久久天天躁夜夜躁狠狠| 色综合久久无码中文字幕| 久久久久久九九99精品| 久久久久夜夜夜精品国产|