View all key methods and memkeys in Memcache and view key usage in real time

Source: Internet
Author: User
In this article, we will share with you how to view and list all the key methods in Memcache and how to use memkeys to view memcachedkey usage in real time. smemkeys is a top-like open-source tumblr tool that can be used to view mem in real time... in this article, we will share with you how to view and list all the key methods in Memcache and how to use memkeys to view memcached key usage in real time. smemkeys is a top-like open-source tumblr tool, it can be used to view the key usage of memcached in real time.

View and list all key methods in Memcache

Today, we are doing a Memcache session test. However, during the test, we found that Memcache does not have a simple method to list all Session keys directly like redis, according to the session content corresponding to the key get, I began to search for information, most of which were commonly used memcache commands, but I did not explain much about how to list keys, so I came to google and found a foreign document.

The specific content I applied in my test environment is as follows.

1. log on to memcache on cmd.

> Telnet to 127.0.0.1 11211

2. list all keys

Stats items // command STAT items: 7: number 1 STAT items: 7: age 188 END

3. get the key through itemid

Next, the list is based on the list of items IDs. In this example, 7 and 2nd parameters are the listed length, and 0 is all listed.

Stats cachedump 7 0 // This is the command ITEM Sess_sidsvpc1473t1np08qnkvhf6j2 [183 B; 1394527347 s] END

4. get the key value through get

The above stats cachedump command lists my session keys, and then uses the get command to find the corresponding session value.

Get requests // This command VALUE limit 1440 1 83 Sess _ | a: 5: {s: 6: "verify"; s: 32: "e70981fd305170c41a5632b2a24bbcaa"; s: 3: "uid"; s: 1: "1"; s: 8: "username"; s: 5: "admin"; s: 9: "logintime"; s: 19: "16:24:25"; s: 7: "log inip"; s: 9: "127.0.0.1 ";}

Memkeys: View memcached key usage in real time

Memkeys

Memkeys is an open-source top-like tool for tumblr. it can be used to view the key usage of memcached in real time.

Install memkeys

Install autoconf (required version 2.68 or later ):

# wget -c http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz # tar zxvf autoconf-latest.tar.gz # cd autoconf-2.69 # ./configure # make && make install 

Install other dependencies:

# Yum install libpcap-devel pcre-devel ncurses-devel

Install memkeys:

# git clone https://github.com/tumblr/memkeys.git # cd memkeys # ./autogen.sh # ./configure # make && make install 

Memkeys usage:

# memkeys -h Usage: memkeys -i NIC [options]     -d, --discard=THRESH        Discard keys where req/s rate is below THRESH     -i, --interface=NIC         Network interface to capture traffic on (required)     -p, --port=PORT             Network port to capture memcache traffic on (default 11211)     -r, --refresh=INTERVAL      Refresh the stats display every INTERVAL ms (default 500)     -l, --logfile=FILE          Output logs to FILE     -R, --report=REPORT         Output data in REPORT format (CSV or curses, default curses)      -h, --help                  This help     -v, --verbose               Increase verbosity. May be used multiple times.     -V, --version               Show program info and exit. 

Example 1: # memkeys-I eth0-l/tmp/memkeys. log

Example 2: # memkeys-I eth0-d 10.0-l/tmp/memkeys. log

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.