-rwxr-xr-x 1 root wheel 153968 Mar 4 2014 /usr/bin/memcached cat /System/Library/LaunchDaemons/com.danga.memcached.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>memcached</string> <key>ProgramArguments</key> <array> <string>/usr/bin/memcached</string> <string>-l</string> <string>127.0.0.1</string> <string>-t</string> <string>4</string> <string>-m</string> <string>64</string> </array> <key>Disabled</key> <true/> <key>KeepAlive</key> <true/> <key>UserName</key> <string>daemon</string> <key>GroupName</key> <string>daemon</string> </dict> </plist>
> memcached -h memcached 1.4.13 -p <num> TCP port number to listen on (default: 11211) -U <num> UDP port number to listen on (default: 11211, 0 is off) -s <file> UNIX socket path to listen on (disables network support) -a <mask> access mask for UNIX socket, in octal (default: 0700) -l <addr> interface to listen on (default: INADDR_ANY, all addresses) <addr> may be specified as host:port. If you don't specify a port number, the value you specified with -p or -U is used. You may specify multiple addresses separated by comma or by using -l multiple times -d run as a daemon -r maximize core file limit -u <username> assume identity of(only when run as root) -m <num> max memory to use for items in megabytes (default: 64 MB) -M return error on memory exhausted (rather than removing items) -c <num> max simultaneous connections (default: 1024) -k lock down all paged memory. Note that there is a limit on how much memory you may lock. Trying to allocate more than that would fail, so be sure you set the limit correctly for the user you started the daemon with (not for -u <username> user; under sh this is done with 'ulimit -S -l NUM_KB'). -v verbose (print errors/warnings while in event loop) -vv very verbose (also print client commands/reponses) -vvv extremely verbose (also print internal state transitions) -h print this help and exit -i print memcached and libevent license -P <file> save PID in , only used with -d option -f <factor> chunk size growth factor (default: 1.25) -n <bytes> minimum space allocated for key+value+flags (default: 48) -L Try to use large memory pages (if available). Increasing the memory page size could reduce the number of TLB misses and improve the performance. In order to get large pages from the OS, memcached will allocate the total item-cache in one large chunk. -D <char> Use as the delimiter between key prefixes and IDs. This is used for per-prefix stats reporting. The default is ":" (colon). If this option is specified, stats collection is turned on automatically; if not, then it may be turned on by sending the "stats detail on" command to the server. -t <num> number of threads to use (default: 4) -R Maximum number of requests per event, limits the number of requests process for a given connection to prevent starvation (default: 20) -C Disable use of CAS -b Set the backlog queue limit (default: 1024) -B Binding protocol - one of ascii, binary, or auto (default) -I Override the size of each slab page. Adjusts max item size (default: 1mb, min: 1k, max: 128m) -o Comma separated list of extended or experimental options - (EXPERIMENTAL) maxconns_fast: immediately close new connections if over maxconns limit - hashpower: An integer multiplier for how large the hash table should be. Can be grown at runtime if not big enough. Set this based on "STAT hash_power_level" before a restart
telnet <hostname> <port>
telnet local 11211
If Memcached server sends ERROR
or CLIENT_ERROR
, something is wrong with the command, if it's SERVER_ERROR
, server itself is in trouble
Parameters :
<key>
: the key of the data stored to retrieve
<key>*
mean you can request value of multiple keys separated by whitespace
These commands return :
VALUE
<flag> <bytes><data> (see the following for explanation of <bytes> and <flag>)
END
indicate the end of response
Get value from key
get <key>*

get key
VALUE key 0 4 data END
Get value from key along with a cas token (to use with cas command)
gets <key>*

get key
VALUE key 0 4 data END
Parameters :
<key>
: the key of the data stored
<flags>
: 32-bit unsigned integer that the server store with the data (provided by the user), and return along the data when the item is retrieved
<exptime>
: expiration time in seconds, 0 mean no delay, if exptime is superior to 30 day, Memcached will use it as a UNIX timestamps for expiration
<bytes>
: number of bytes in the data block
<cas unique>
: unique 64-bit value of an existing entry (retrieved with gets command) to use with cas command
[noreply]
: optional parameter that inform the server to not send the reply
These commands can return :
STORED
to indicate success
NOT_STORED
indicate that the data was not stored because condition for "add" or "replace" command wasn't met, or the item is in a delete queue
EXISTS
indicate that the item you are trying to store with "cas" command has been modified since last fetch
NOT_FOUND
indicate that the item did not exist or has been deleted
Store key/value pair in Memcached
set <key> <flags> <exptime> <bytes> [noreply]
<value>

set key 0 900 4 data
STORED
Store key/value pair in Memcached, but only if the server doesn't already hold data for this key
add <key> <flags> <exptime> <bytes> [noreply]
<value>

add key 0 900 2 10
STORED
Store key/value pair in Memcached, but only if the server already hold data for this key
replace <key> <flags> <exptime> <bytes> [noreply]
<value>

replace key 0 900 2 10
STORED
Add value to an existing key after existing data
Append does not take <flags> or <exptime> parameters but you must provide them !
append <key> <flags> <exptime> <bytes> [noreply]
<value>

append key 0 900 2 10
STORED
Add value to an existing key before existing data
Prepend does not take <flags> or <exptime> parameters but you must provide them !
prepend <key> <flags> <exptime> <bytes> [noreply]
<value>

prepend key 0 900 2 10
STORED
Store data only if no one else has updated since the last fetch, determined with the cas tokem from gets command
cas <key> <flags> <exptime> <bytes> <cas unique> [noreply]

cas key 0 900 2 <cas unique> 10
STORED
Parameters :
<key>
: the key to delete
[<time>]
: optional time in second before real deletion of item
[noreply]
: optional parameter that inform the server to not send the reply
These command can return :
DELETED
to indicate success
NOT_FOUND
indicate that the item did not exist or has been deleted
Store key/value pair in Memcached
delete <key> [<time>] [noreply]

delete key
DELETED
Parameters :
<key>
: the key to delete
<value>
: the amount to increase/decrease the item.
[noreply]
: optional parameter that inform the server to not send the reply
These command can return :
NOT_FOUND
indicate that the item did not exist or has been deleted
<value>
increment and decrement return the result
Increment value associated with key in Memcached, item must exist, increment command will not create it
The limit of increment is the 64 bit mark
incr <key> <value> [noreply]

incr key 12
56
Decrement value associated with key in Memcached, item must exist, decrement command will not create it
If you try to decrement a value bellow 0, value will stay at 0
decr <key> <value> [noreply]

decr key 12
44
Parameters :
<key>
: the key to delete
<exptime>
: is expiration time. Works the same as with the update commands (set/add/etc). This replaces the existing expiration time.
[noreply]
: optional parameter that inform the server to not send the reply
These command can return :
NOT_FOUND
indicate that the item did not exist or has been deleted
TOUCHED
to indicate success
The "touch" command is used to update
the expiration time of an existing item without fetching it.
touch <key> <exptime> [noreply]

touch key 1800
TOUCHED
Parameters :
<args>
: argument to stats command
These command can return various stats that we will explain in the following
Return general-purpose statistics like uptime, version, memory occupation, ...
stats

stats
STAT pid 106796 STAT uptime 5696 STAT time 1274397461 STAT version 1.4.5 STAT pointer_size 32 ... STAT total_items 344512124 STAT evictions 0 END
Return items statistics, will display items statistics (count, age, eviction, ...) organized by slabs ID
stats items

stats
STAT items:1:number 1125 STAT items:1:age 426 STAT items:1:evicted 0 STAT items:1:evicted_nonzero 0 STAT items:1:evicted_time 0 STAT items:1:outofmemory 0 STAT items:1:tailrepairs 0 ... STAT items:42:tailrepairs 0 END
Return slabs statistics, will display slabs statistics (size, memory usage, commands count, ...) organized by slabs ID
stats slabs

stats
STAT 1:chunk_size 80 STAT 1:chunks_per_page 13107 STAT 1:total_pages 1 STAT 1:total_chunks 13107 STAT 1:used_chunks 1125 ... STAT active_slabs 25 STAT total_malloced 10485600 END
Flush the server key/value pair (invalidating them) after a optional [<time>] period
It always return OK
flush_all [<time>] [noreply]

flush_all 10
OK
Return the Memcached server version
version

version
VERSION 1.4.5
Change the verbosity ouptut of Memcached server
It always return OK
verbosity <level> [noreply]

verbosity 2
OK
quit

quit
For any advanced need Memcached text protocol
can be found here
You can find a lot of Memcached resources on Memcached resources page.
Copied from:Elijaa.org