memcached Common Commands

Source: Internet
Author: User
Tags memcached perl script

See: http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt104

Memcache Common object-oriented interfaces include:
Memcache::connect-Open a connection to Memcache
Memcache::p connect-Open a long connection to Memcache
memcache::close-Closing a Memcache connection
memcache::set-saving data to the Memcache server
memcache::get-extract a data stored on the Memcache server
memcache::replace-Replace an item that already exists on the Memcache server
Memcache::d elete-Delete a saved item from the Memcache server
memcache::flush-refreshes all items saved on the Memcache server (similar to deleting all saved items)
memcache::getstats-getting the status of the current Memcache server running

For More:http://cn.php.net/memcache

Second, check the operating status of the system:

[[Email protected] softwear]# telnet 127.0.0.1 11211
Trying 127.0.0.1 ...
Connected to Localhost.localdomain (127.0.0.1).
Escape character is ' ^] '.
Stats input stats, display server information, statistic data, etc.
STAT PID 8257 Process ID
STAT uptime 683101 server running seconds
STAT time 1288179433 Server current UNIX timestamp
STAT version 1.2.6 memcached version
STAT pointer_size 32 pointer size for current operating system (32-bit system is typically 32bit)
STAT rusage_user 7.269894 Cumulative User time for this process
STAT Rusage_system 27.697789 System time accumulated by this process
STAT Curr_items 8311 The amount of content currently stored by the server
STAT total_items 255141 Total content that has been stored since the server was started
STAT bytes 4875895 The number of bytes consumed by the server currently storing content
STAT curr_connections 12 Number of currently open connections
STAT total_connections 131 Total connections received since the server was running
STAT connection_structures 13 Number of connection structures allocated by the server
STAT cmd_get 534959 Execute get command total
STAT cmd_set 255507 Execute SET command total
STAT get_hits 279452 Get hit Count
STAT get_misses 255507 Get Miss Count
STAT Evictions 0 The total number of items to get the space deleted (the space allocated to memcache needs to be removed when the old item is filled to get the space allocated to the new items)
STAT bytes_read 217230173 Total number of bytes read from the network by the server
STAT Bytes_written 246524464 The total number of bytes sent to the network by the server
STAT limit_maxbytes 134217728 The total number of bytes that the server is allowed to use when it is stored, the amount of memory allocated (bytes), this is 128M
STAT threads 1 Current thread count
END

Among them, several important parameters are:
Uptime: Is the number of seconds the memcached is running.
Cmd_get: Is the number of query caches.
Cmd_get/uptime result is the average number of requests per second of cache-the larger the result value, the higher the memcached utilization, the greater the site's access, and if it is too low, the file system cache will do, and it will not reflect the powerful performance of using memcached.
Cmd_set: Is the number of times the Key=>value is set. The whole memcached is a big hash, with Cmd_get not found content, will call Cmd_set write into the cache.
Get_hits: Is the number of cache hits. The so-called hit rate = Get_hits/cmd_get * 100%.
Get_misses: Is the number of cache misses. Get_misses plus get_hits equals Cmd_get.
Stats: Display server information, statistics, etc.
Stats Reset: Emptying statistics

Stats Slabs: Displays information about each slab, including the size, number, usage, etc. of the chunk
Stats items: Displays the number of item in each slab and the length of storage (the number of seconds the last access distance is now)
Quit: Quit

Third, using shell command operation memcached

1. View memcached state at the time
printf "stats\r\n" | NC 127.0.0.1 11211

2. View memcached real-time status
Watch "printf ' stats\r\n ' | NC 127.0.0.1 11211″

Memcached protocol in English documents can be consulted: http://blog.s135.com/book/memcached/

Four. View the usage status of slabs
Using memcached, a Perl script named Memcached-tool, written by Brad, makes it easy to get slab usage (IT organizes memcached return values into easy-to-read formats). You can get the script from the following address:
Http://code.sixapart.com/svn/memcached/trunk/server/scripts/memcached-tool
[Email protected] html]# vim Memcached-tool
[Email protected] html]# chmod +x memcached-tool
[Email protected] html]#/memcached-tool 127.0.0.1:11211
# item_size Max_age 1mb_pages Count full?
1 B 0 S 1 0 No
2 104 B 12175 s 1 1 No
3 176 B 1339587 s 196567 Yes

The meaning of each column:
#: Slab class Number
Item_size:chunk size
Life time of oldest record in Max_age:lru
1mb_pages: Number of pages assigned to slab
Number of records in Count:slab
Full?: Slab contains idle chunk

Five. can also graphically monitor the operation status of Memcached
http://livebookmark.net/journal/2008/05/21/memcachephp-stats-like-apcphp/
is a PHP source file, only need to modify the source code in the user name, password and array $memcache_servers on it.

memcached Common Commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.