Memcache Introductory Learning Materials

Source: Internet
Author: User
Tags cas


First, what is memcached
Website address: http://memcached.org/
Memcached is a high-performance distributed memory object caching system. It increases data acquisition speed by caching data and objects in memory to reduce the number of data reads.
Memcached is based on a hashmap that stores key/value pairs. Its daemon (daemon) is written in C, but the client can be written in any language,
and communicates with the daemon through the memcached protocol. However, it does not provide redundancy (for example, copying its hashmap entries);
When a server s stops running or crashes, all key/value pairs stored on it are lost.
Memcached was developed by Danga Interactive, and the latest version was released in 2010 by the author of Anatoly Vorobey and Brad Fitzpatrick.
Used to increase the speed of livejournal.com access. LJ Dynamic page visits thousands of times per second, user 7 million.
Memcached significantly reduces database load, better allocation of resources, faster access.


Second, open/stop service
1. The commands that typically start a memcached process are:
Memcached-d-M 6048-u root-p 11211-c 1024-p/tmp/memcached.pid start memcached Service
The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, I'm 10MB,
-U is the user running memcache, I am root here,
-L is the server IP address of the listener, if there are more than one address, I specify the server IP address 127.0.0.1, the default is the native
-P is the port that sets Memcache listening, I set up here 11211 preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, which is set by default at 1024, based on the amount of load on your server.
-P is set to save memcache PID file, I am here to save in/tmp/memcached.pid.

2. Stop memcached Service
Kill ' Cat/tmp/memcached.pid ' stop all
Kill + Process Sequence number


Third, the use of common API interface
Add is saved only if there are no data with the same key in the storage space
Replace is replaced when it exists in the cache, otherwise it is not processed.
Set store/or replace storage k\v key-value pairs
Delete Deletes the specified key
Get Get Data


Iv. getting the service to move the state of the line
Echo Stats | NC 192.168.100.60 11211 Get execution Command time state
Watch "Echo Stats | NC 192.168.100.60 11211 "(real-time status)
Parameter explanation:
STAT PID 22459 Process ID
STAT uptime 1027046 server running seconds
STAT time 1273043062 Server current UNIX timestamp
STAT version 1.4.4 Server version
STAT pointer_size 64 OS Word size (this server is 64-bit)
STAT rusage_user 0.040000 Process Cumulative User Time
STAT rusage_system 0.260000 Process Cumulative system time
STAT curr_connections 10 Number of currently open connections
STAT total_connections 82 Total connections that were opened
STAT connection_structures 13 Number of connection structures allocated by the server
STAT cmd_get 54 Execute Get Command Total
STAT Cmd_set 34 Execute SET command total
STAT Cmd_flush 3 points to the total number of FLUSH_ALL commands
STAT get_hits 9 Get hit count
STAT get_misses number of Get misses
STAT delete_misses 5 Delete misses
STAT delete_hits 1 Delete hit count
STAT incr_misses 0 incr number of misses
STAT incr_hits 0 incr hit count
STAT decr_misses 0 decr number of misses
STAT decr_hits 0 DECR hit count
STAT cas_misses 0 CAs misses
STAT cas_hits 0 CAs hit count
STAT Cas_badval 0 Use wipe count
STAT Auth_cmds 0
STAT auth_errors 0
STAT bytes_read 15785 Read Bytes total
STAT bytes_written 15222 Write Bytes Total
STAT limit_maxbytes 1048576 Allocated memory number (bytes)
STAT Accepting_conns 1 Number of links currently accepted
STAT Listen_disabled_num 0
STAT Threads 4 Thread Count
STAT Conn_yields 0
STAT bytes 0 Stores the item byte number
STAT Curr_items 0 Item number
STAT total_items Total number of item
STAT evictions 0 To get the total amount of space deleted item

Memcache Introductory Learning Materials

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.