Developing a
memcached
Application
1378
Both text lines (commands and responses) and unstructured data are always terminated with the string
\r\n
. Because the data being stored may contain this sequence, the length of the data (returned by
the client before the unstructured data is transmitted should be used to determine the end of the data.
Commands to the server are structured according to their operation:
• Storage commands:
set
,
add
,
replace
,
append
,
prepend
,
cas
Storage commands to the server take the form:
command key [flags] [exptime] length [noreply]
Or when using compare and swap (cas):
cas key [flags] [exptime] length [casunique] [noreply]
Where:
•
command
: The command name.
•
set
: Store value against key
•
add
: Store this value against key if the key does not already exist
•
replace
: Store this value against key if the key already exists
•
append
: Append the supplied value to the end of the value for the specified key. The
flags
and
exptime
arguments should not be used.
•
prepend
: Append value currently in the cache to the end of the supplied value for the specified
key. The
flags
and
exptime
arguments should not be used.
•
cas
: Set the specified key to the supplied value, only if the supplied
casunique
matches.
This is effectively the equivalent of change the information if nobody has updated it since I last
fetched it.
•
key
: The key. All data is stored using a the specific key. The key cannot contain control characters
or whitespace, and can be up to 250 characters in size.
•
flags
: The flags for the operation (as an integer). Flags in
memcached
are transparent. The
memcached
server ignores the contents of the flags. They can be used by the client to indicate
any type of information. In
memcached
1.2.0 and lower the value is a 16-bit integer value. In
memcached
1.2.1 and higher the value is a 32-bit integer.
•
exptime
: The expiry time, or zero for no expiry.
•
length
: The length of the supplied value block in bytes, excluding the terminating
\r\n
characters.
•
casunique
: A unique 64-bit value of an existing entry. This is used to compare against the
existing value. Use the value returned by the
gets
command when issuing
cas
updates.
•
noreply
: Tells the server not to reply to the command.
For example, to store the value
abcdef
into the key
xyzkey
, you would use:
set xyzkey 0 0 6\r\nabcdef\r\n
The return value from the server is one line, specifying the status or error information. For more
information, see
Table 15.3, “
memcached
Protocol Responses”
.
• Retrieval commands:
get
,
gets
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...