memcached telnet commands

Sunday, September 19th, 2010 at 2:21 pm | Tutorials

You can access and control your memcached installation, using simple telnet commands. Use ps -ef to determine on which port and ip you memcached server is running and connect to it:

telnet localhost 11211

The list of commands is as follows:

Get stored data

get <key>*

Returns the value stored for this key. You can specify more than one keys separated by spaces.

Store data

[set|add|replace|append|prepend] <key> <flags>
<exp_time> <bytes> [no_reply]

The arguments are:

  • flags: an arbitrary 16-bit unsigned integer (written out in decimal) that the server stores along with the data and sends back when the item is retrieved.
  • exp_time: expiration time in seconds. If it’s 0, the item never expires (although it may be deleted from the cache to make place for other items).
  • bytes: the number of bytes in the data block to follow, *not* including the delimiting \r\n. <bytes> may be zero (in which case it’s followed by an empty data block).

After the command hit Enter and input the data block of size <bytes>.

Return values:

  • STORED
  • NOT_STORED

Delete data

delete <key> [<time>] [noreply]

Delete a key.

  • time: 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.

Flush all stored data

flush_all

Flashes the entire cache.

Other commands

stats

General statistics

stats slabs

Memory statistics

stats memory

Memory statistics

stats items

Higher level statistics

quit

Quit the telnet interface

Be Sociable, Share!

Tags: , , ,

3 Responses to “memcached telnet commands”

  1. Jonathan Day says:

    Very helpful, thanks. Do you know if there is any way to get a list of the currently cached keys? The get command is not particularly helpful without a list..

  2. ehcache.net says:

    memcached telnet commands…

    You can access and control your memcached installation, using simple telnet commands. Use ps -ef to determine on which port and ip you memcached server is running and connect to it: telnet localhost 11211The list of commands is as follows: Get stored d…

Leave a Reply