Memcache scrutiny (i)

Source: Internet
Author: User

Memcached is a high-performance distributed memory cache server. Developed by the development team of LiveJournal, a foreign community website.

Purpose of Use:

Reduce the number of database accesses by caching database query results to improve the speed and scalability of dynamic Web applications.

Memcache is a free and open source, high performance, distributed memory object caching system. Used to accelerate dynamic Web applications and reduce database load.

Characteristics of MEMCAHCE

1, based on C/S architecture, simple protocol

2, based on Libevent event processing {Libevent is an event-triggered network library for a variety of platforms such as Windows, Linux, BSD (Unix derived systems)}

3. Internal Memory storage mode

4, client-based memcached distributed

Applicable scenarios

1, the need for distributed deployment (what is distributed: If a task has 10 sub-tasks, the 10 subtasks are placed separately to 10 servers, greatly shorten the task execution time,)

2. Frequent access to the same data

3, the need for data sharing

Introduction of C/S architecture

Installation Start (see PDF document)

The use of various commands

Set/add/replace/delete/get/gets/cas/stats/stats Items/append/prepend/flush_all, wait.

Memcahced Some features and limitations

① there is no limit to the amount of item data that can be saved in memcached, only enough memory

②memcached single process maximum memory is 2G, to use more memory, you can open multiple memcached processes on multiple ports

③ Maximum 30 days of data expiration, set to permanent will also expire at this time, constant Realtime_maxdelta

④60*60*24*30 Control

⑤ maximum key length is 250 bytes, greater than this length cannot be stored, constant key_max_length 250 control

⑥ Single Item maximum data is 1MB, more than 1MB data is not stored, constant Power_block 1048576 is controlled,

⑦ It is the default slab size

⑧ maximum number of simultaneous connections is 200, controlled by the freetotal in Conn_init (), the maximum number of soft connections is 1024, by

⑨settings.maxconns=1024 control ⑩ parameters related to space occupancy: settings.factor=1.25, settings.chunk_size=48, data occupancy and stepping methods that affect slab

memcached Configuration
/********************************************/
$mem _ip= ' 127.0.0.1 ';
$mem _port=11211;
$mem _prefix= ';
/********************************************/

/********************************************/
Session memcached configuration, please configure to a separate Memcache service (different IP or different port number),
Several mirror stations must be set to the same, otherwise it will cause the session to be lost
No other program can use this service to avoid conflicts.
/********************************************/
$session _mem_ip= ' 127.0.0.1 ';
$session _mem_port=11212;

function instance_memcached ()
{
Static $mem =false;
if ($mem ==false && isset ($GLOBALS [' mem_ip ') && isset ($GLOBALS [' Mem_port ']) && Extension_ Loaded (' Memcache '))
{
$mem =new Memcache;
$mem->pconnect ($GLOBALS [' mem_ip '], $GLOBALS [' mem_port ']) or Die (' Can not connect to memcache server! ');
}
return $mem;
}

Memcache scrutiny (i)

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.