Memcache View list all key methods and Memkeys Live View key Usage

Source: Internet
Author: User
Tags memcached git clone

Memcache View List all key methods

Today is doing a memcache session test, but in the process of testing, found memcache not a simpler way to directly like Redis like the keys * List all the session key, and according to the key get corresponding session content , so, I began to look up data, most of them turned out are some memcache commonly used commands, but the way to list key, but not much, so came to Google, found a foreign information


The specific content I apply to my test environment, operates as follows

1. CMD login memcache

> Telnet 127.0.0.1 11211

2. List all keys

Stats items//This one is an order.
STAT Items:7:number 1
STAT Items:7:age 188
End

3. Get key through Itemid

Next, based on the items ID listed, this example is 7, the 2nd parameter is the length listed, and 0 is all listed
Stats cachedump 7 0//This one is an order.
ITEM Sess_sidsvpc1473t1np08qnkvhf6j2 [183 B; 1394527347 S]
End

4. Get key value

The above stats cachedump command lists my session key and then uses the GET command to find the corresponding session value
Get SESS_SIDSVPC1473T1NP08QNKVHF6J2//This one is an order
VALUE
SESS_SIDSVPC1473T1NP08QNKVHF6J2 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: "2014-03-11 16:24:25"; s:7: "Log
Inip "; S:9:" 127.0.0.1 ";}


Memkeys Real-time view of memcached key usage

Memkeys

Memkeys is a Tumblr open source similar to top tool that can be used to view memcached key usage in real time.

Memkeys Installation

Install autoconf (more than 2.68 version required):
# 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 additional 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 use

# 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 the format (CSV or curses, default curses)

-H,--help this Help
-V,--verbose increase verbosity. May is 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.