This is a discussion on Why we need Memcache? within the PHP Programming forums, part of the Web Development category; <cas unique> is a unique 64-bit value of an existing entry. Clients should use the value returned ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| <cas unique> is a unique 64-bit value of an existing entry. Clients should use the value returned from the "gets" command when issuing "cas" updates.
__________________ With, J. Jeyaseelan Everything Possible |
| Sponsored Links |
| |||
| "noreply" optional parameter instructs the server to not send the reply. NOTE: if the request line is malformed, the server can't parse "noreply" option reliably. In this case it may send the error to the client, and not reading it on the client side will break things. Client should construct only valid requests.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| After the above, the client sends the data block: <data block>\r\n - <data block> is a chunk of arbitrary 8-bit data of length <bytes> from the previous line. 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" 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). - "EXISTS\r\n" to indicate that the item you are trying to store with a "cas" command has been modified since you last fetched it. - "NOT_FOUND\r\n" to indicate that the item you are trying to store with a "cas" command did not exist or has been deleted.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Quote:
It will usually use very little CPU, so fire it up wherever there's free ram.
__________________ Regards, Senraj.A |
| |||
| The retrieval commands "get" and "gets" operates like this: in this <key>* means one or more key strings separated by whitespace.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| 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" to indicate the end of response.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Each item sent by the server looks like this: VALUE <key> <flags> <bytes> [<cas unique>]\r\n <data block>\r\n - <key> is the key for the item being sent
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| 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).
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Deletion The command "delete" allows for explicit deletion of items: delete <key> [<time>] [noreply]\r\n - <key> is the key of the item the client wishes the server to delete - <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. 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). - "noreply" optional parameter instructs the server to not send the reply. See the note in Storage commands regarding malformed requests.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| 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 invalidation of all existing items.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| 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 64-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.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The client sends the command line: incr <key> <value> [noreply]\r\n or decr <key> <value> [noreply]\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/decrease the item. It is a decimal representation of a 64-bit unsigned integer. - "noreply" optional parameter instructs the server to not send the reply. See the note in Storage commands regarding malformed requests.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| the response for the above 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.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| 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 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 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.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| If you have a high-traffic site that is dynamically generated with a high database load that contains mostly read threads then memcached can help lighten the load on your database.
__________________ Regards, Senraj.A |
| |||
| Statistics 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 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 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.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| "flush_all" is a command with an optional numeric argument. It always succeeds, and the server sends "OK\r\n" in response (unless "noreply" is given as the last parameter). 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.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The intent of flush_all with a delay, was that in a setting where you have a pool of memcached servers, and you need to flush all content, you have the option of not resetting all memcached servers at the same time (which could e.g. cause a spike in database load with all clients suddenly needing to recreate content that would otherwise have been found in the memcached daemon). The delay option allows you to have them reset in e.g. 10 second intervals (by passing 0 to the first, 10 to the second, 20 to the third, etc. etc.).
__________________ With, J. Jeyaseelan Everything Possible |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to delete memcache? | Kamalakannan | PHP Programming | 11 | 10-25-2007 11:30 PM |
| memcache commands and behavior | prasath | Database Support | 4 | 09-27-2007 12:04 AM |
| Phpaccelerator & Memcache | sivaramakrishnan | PHP Programming | 0 | 08-31-2007 07:59 AM |
| Memcache with Mysql | write2ashokkumar | Database Support | 0 | 08-02-2007 02:41 AM |
| memcache in PHP | DuraiBabu | PHP Programming | 6 | 07-18-2007 12:43 AM |