The memcached of Linux-nosql

Source: Internet
Author: User

1.memcached Installation

Yum Search memcached

Yum install-y libevent memcached libmemcached

Start:/etc/init.d/memcached start

Viewing the Listening port: NETSTAT-LNP |grep Memcached|netstat-naput

Ps-aux |grep memcached

Define Startup parameters: Vim/etc/sysconfig/memcached

-D: Start a daemon

-P: Listening port

-C: Maximum number of concurrent connections running

M: Amount of memory allocated to memcached

-L: Listening server IP address

-P: Set the PID file to save memcached

View memcached Status:

Memcached-tool 127.0.0.1:11211 Stats

or echo stats |nc 127.0.0.1 11211 need to install NC tools

2.memcached Basic Operation

Connection: Telnet 127.0.0.1 11211

first, the format of the stored command: <command name> <key> <flags> <exptime> <bytes> <data block>

The parameters are described as follows:

<command name> Set/add/replace
<key> Find keywords
<flags> The client uses it to store extra information about key-value pairs
<exptime> The survival time of this data, 0 means forever
<bytes> Number of bytes stored
<data block> Stored data blocks (can be directly understood as value in the key-value structure)

This set command is used very frequently in memcached. The set command can not only be added simply, if the set key already exists, the command can update the key corresponding to the original data, that is, to achieve the role of the update.

You can view the added records in the "Get Key Name" mode.

Remove it with the Delete command and add it again

"The set that is stored anyway

"Add when the data does not exist ."

"Replace when the data exists

Second, read command 1, get

The key of the GET command can represent one or more keys, separated by a space

2, gets

The GET command returns a number (medium 13) More than the normal gets command. This number checks to see if the data has changed. When the data corresponding to the key changes, the number returned will also change.

3. CAs

CAS is the meaning of checked and set, which can only be stored if the last parameter matches the parameters obtained by the GET, otherwise "EXISTS" is returned.

Iii. status Commands 1, stats2, stats items

Perform stats items, you can see the stat items row, if the memcached stores a lot of content, then there will be a lot of stat items listed here.

3, stats cachedump slab_id limit_num

We perform the stats cachedump 1 0 command effect as follows:

The slab_id here is 1, which is determined by the results returned by the stats items in 2 (the number following the STAT items); Limit_num looks like it's going to return as many records as it's worth, but 0 means it shows all the records, and N (n>0) Indicates that N records are displayed, and if n exceeds all records under the slab, the result is the same as the result returned by 0.

The memcached of Linux-nosql

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.