Interaction with the memcached Server

Source: Internet
Author: User
Interaction with memcached server comments type 1. storage commands: Set add replace2. retrieval commands: get3. other commands: incr deleteerror strings1. "error/R/N" the client sent a command2. "client_error <error>/R/N" client error: the data or format sent by the client is incorrect. <Error> indicates the cause of the error. 3. "server_error <error>/R/N" server error: A series of server errors prevent command execution. <Error> indicates the cause of the error. When this error occurs. After the server sends "server_error <error>/R/N", the connection is closed. (This is the only case where connection is closed) descriptions of individual commands1. storage commands first the client sends the command line to the server in the following format: <command name> <key> <flags> <exptime> <bytes>/R/NA) <command name> can be set, add, and replace ". "Set" indicates that the data is stored according to the corresponding <key>. "Add" means to add the data according to the corresponding <key>, but if the <key> already exists, the Operation will fail. "Replace" indicates that the data is replaced according to the corresponding <key>, but if the <key> does not exist, the operation fails. B) <key> the key of the data to be saved on the client. C) <flags> is a 16-bit unsigned integer (expressed in decimal format ). This flag is stored together with the data to be stored and returned when the client get data. The customer can use this flag for special purposes, which is not transparent to the server. D) <exptime> expiration time. If the value is 0, the stored data will never expire (however, the data may be replaced by other items. This is because the server uses the LRU (not used for the longest time) algorithm ). If it is not 0 (UNIX time or the number of seconds from this time point), after expiration, the server can ensure that the user does not get the data (based on the server time ). E) <bytes> the number of bytes to be stored (excluding the last "/R/N"). If you want to store empty data, the value <bytes> can be 0f) the client must add "/R/N" as the end mark of the "Command Header. <Data block>/R/N and the "Command Header" are followed by a data block (that is, the data content to be stored ), add "/R/N" as the end of the communication. When the above data is sent, the server returns a response. There may be the following situations: a) "stored/R/N" indicates that the storage is successful B) "not_stored/R/N" indicates that the storage fails, but this failure is not due to an error. This is usually caused by the requirements of the "add" or "replace" command itself, or the item is in the delete Queue (see the DELETE command ). 2 retrieval command: Get <key> */R/NA) <key> * indicates one or more keys (separated by spaces) B) the end of the "/R/N" command header reply the server returns 0 or more data items. Each data item is composed of a text row and a data block. When all data items are received, the data structure of "End/R/N" is received: value <key> <flags> <bytes>/R/n <data block>/R/NA) <key> keyb for storing data) <falg> flag C set when sending the SET command) <bytes> length of the data block to be sent (excluding "/R/N") d) "/R/N" indicates the end sign of the text line E) <data block> the data item to be received. F) "/R/N" receives the end mark of a data item. If some keys appear in the GET command line but no corresponding data is returned, this means that these items do not exist in the server. These items are outdated or deleted. 3. deletedelete Command Format: delete <key> <time>/R/NA) <key> keyb of the data to be deleted) <time> time when the client wants the server to delete the data (UNIX time or number of seconds from now) C) "/R/N" command header end replya) "Deleted/R/N" deleted successfully B) "not_found/R/N" The Key To be deleted does not exist. PS: "flush_all" command can invalidate all items. 4. Increment/decrementcommand "incr" "decr" is a command used to change the value of a data item. The data set for the data item is considered to be a 10-digit unsigned integer. If the currently set value cannot be converted, it is regarded as 0. If the key of the data item does not exist, the command fails to be executed! Command Format: incr <key> <value>/R/nordecr <key> <value>/R/NA) <key> keyb of the data item) <value> the value of the data you want to increase/decrease. the value is a 32-bit unsigned integer variable. C) "/R/N" Command Line End mark replya) "not_found/R/N" does not find the item to be operated. B) "<value>/R/N" <value> the latest remaining time of the data item validity period. Note: a) if the validity period of a data item is set to 0, the decr command cannot reduce the data. B) If you want to perform the incr key-1 operation, the result is the same as what you want. However, the result of executing decr-1 will surprise you, because the result of decr-1 is zero regardless of the data of the key. the reason is: during the execution of these two commands, it is like-1 as an unsigned integer. C) when running the decr command, the data length does not decrease, but fills in spaces after the returned data. However, when the incr command is executed out of bounds, the number of data digits is automatically increased. 5. Other commands "stats": Used to query internal data provided by the server. Stats <ARGs>/R/n query specific data replystat <Name> <value>/R/n... end/R/N "quit" "Quit/R/N": exit the program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.