|
NewCommands
Make Me a Sandwich
Memcached handles a small number of basic commands. Full documentation can be found in the Protocol Documentation. Standard ProtocolThe "standard protocol stuff" of memcached involves running a command against an "item". An item consists of:
CAS is optional (can be disabled entirely with -C, and there are more fields that internally make up an item, but these are what your client interacts with. No ReplyMost ASCII commands allow a "noreply" version. One should not normally use this with the ASCII protocol, as it is impossible to align errors with requests. The intent is to avoid having to wait for a return packet after executing a mutation command (such as a set or add). The binary protocol properly implements noreply (quiet) statements. If you have a client which supports or uses the binary protocol, odds are good you may take advantage of this. Storage CommandssetMost common command. Store this data, possibly overwriting any existing data. New items are at the top of the LRU. addStore this data, only if it does not already exist. New items are at the top of the LRU. If an item already exists and an add fails, it promotes the item to the front of the LRU anyway. replaceStore this data, but only if the data already exists. Almost never used, and exists for protocol completeness (set, add, replace, etc) appendAdd this data after the last byte in an existing item. This does not allow you to extend past the item limit. Useful for managing lists. prependSame as append, but adding new data before existing data. casCheck And Set (or Compare And Swap). An operation that stores data, but only if no one else has updated the data since you read it last. Useful for resolving race conditions on updating cache data. Retrieval CommandsgetCommand for retrieving data. Takes one or more keys and returns all found items. getsAn alternative get command for using with CAS. Returns a CAS identifier (a unique 64bit number) with the item. Return this value with the cas command. If the item's CAS value has changed since you gets'ed it, it will not be stored. deleteRemoves an item from the cache, if it exists. incr/decrIncrement and Decrement. If an item stored is the string representation of a 64bit integer, you may run incr or decr commands to modify that number. You can incr by positive or negative values, so decr is included for completeness. If a value does not already exist, incr/decr will fail. StatisticsThere're a handful of commands that return counters and settings of the memcached server. These can be inspected via a large array of tools or simply by telnet or netcat. These are further explained in the protocol docs. statsye 'ole basic stats command. stats itemsReturns some information, broken down by slab, about items stored in memcached. stats slabsReturns more information, broken down by slab, about items stored in memcached. More centered to performance of a slab rather than counts of particular items. stats sizesA special command that shows you how items would be distributed if slabs were broken into 32byte buckets instead of your current number of slabs. Useful for determining how efficient your slab sizing is. WARNING this is a development command. As of 1.4 it is still the only command which will lock your memcached instance for some time. If you have many millions of stored items, it can become unresponsive for several minutes. Run this at your own risk. It is roadmapped to either make this feature optional or at least speed it up. flush_allInvalidate all existing cache items. Optionally takes a parameter, which means to invalidate all items after N seconds have passed. This command does not pause the server, as it returns immediately. It does not free up or flush memory at all, it just causes all items to expire. |
For statistics, theres a note that "These can be inspected via a large array of tools". It would be great with a notion of a small subset of common tools, for us newcomers! Best regards and thanks for a superb product Johan Höglund, Sweden
would u please list the parameter of the comand?
Just set... balala... means nothing. Everyone knows what set is.
I agree, according to the front of memcached.org for example, GET returns "VALUE foo 0 2\n", what does 0 and 2 mean?
i'm wondering if it's possible to update the protocol to include the command to write and read subset of the value(ofsett, len). Memcached is a very well done piece of software and with this update will be the best. In my project i really need this features. Is this feature simple to integrate into Memcached?