Kill lui lei Dog---memcache no:05 configuration of a distributed memory object cache system

Source: Internet
Author: User

To build a distributed cache system.

(1) More than one memcache server

(2) Distributed algorithm. From which data is stored, the data is obtained from which station.

The algorithm is built-in, without our own intervention, built into the memcache extension inside.

When we use multiple memcache operations, we operate on the same machine.

Steps to Build:

Prepare at least two memcache servers.

localhost:11211

localhost:11210

The storage methods are as follows:

<? PHP $mem New Memcache (); // Link a distributed memcache server//Add a memcache server to the connection pool $mem -addserver (' localhost ', 11211); $mem -addserver (' localhost ', 11210); $mem , set (' Name ', ' Lisi ', 0,3600); $mem , set (' Age ', 23,0,3600); $mem -Set (' Email ', ' [email protected] ', 0,3600

The Read method is as follows:

<? PHP $mem New Memcache (); // Link a distributed memcache server//Add a memcache server to the connection pool $mem -addserver (' localhost ', 11211); $mem -addserver (' localhost ', 11210); Var_dump ($mem,get (' name ')); Var_dump ($mem,get (' age ')); Var_dump ($mem->get (' email '));

When adding data is, the number and order of Memcache servers that connect multiple memcache servers to and from the page to fetch the data should always be, reason: is to use the go-to-touch algorithm

Modulus algorithm: When data is stored and taken out, a value is calculated from key, divided by the number of servers, which determines which server to add data to and fetch data from.

Kill lui lei Dog---memcache no:05 configuration of a distributed memory object cache system

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.