Php memcache module optimization configuration

Source: Internet
Author: User
Tags crc32

Memcache support Enabled
Active persistent connections 0
Revision $ Revision: 1.92 $

Directive Local Value Master Value
Memcache. allow_failover 1 1
Memcache. chunk_size 8192 8192
Memcache. default_port 11211 11211
Memcache. hash_function Crc32 Crc32
Memcache. hash_strategy Standard Standard
Memcache. max_failover_attempts 20 20

Find some information about the optimization of the php memcache module on the Internet and paste it out.

The code is as follows: Copy code

Vi/etc/php. d/memcache. ini
[Memcache]
; Enable memcache extension module
Extension = memcache. so
Memcache. allow_failover = "1"
Memcache. max_failover_attempts = "20"
Memcache. chunk_size = "8192"
Memcache. default_port = "11211"
Memcache. hash_strategy = "standard"
Memcache. hash_function = "crc32"

Ps:

The code is as follows: Copy code
Memcache. allow_failover = "1"

A Boolean value used to control whether the Memcache extension fails over to other servers when a connection error occurs. The default value is 1 (true ).

The code is as follows: Copy code

Memcache. max_failover_attempts = "20"

An integer value used to limit the number of servers connected to persistent data or retrieved data. If memcache. allow_failover is false, this parameter is ignored. The default value is 20.

The code is as follows: Copy code
Memcache. chunk_size = "8192"

An integer value used to control the data transmission size. The default value is 8192 bytes (8 KB), but if it is set to 32768 (32 KB), it can achieve better performance.

The code is as follows: Copy code

Memcache. default_port = "11211"

Another integer value is used to set the TCP port used to connect to Memcache. The default value is unprivileged high port 11211 unless you modify it.

The code is as follows: Copy code

Memcache. hash_strategy = "standard"

Hash Policy. Currently there are standard and consistent modes. standard modes are actually %, that is, modulo. And consistent, which is more complicated. memcache. hash_function = "crc32"
Controls which hrated function is applied to key ing to the server. The default value "crc32" uses the CRC32 algorithm, while "fnv" indicates that the FNV-1a algorithm is used.

Test memcache

The code is as follows: Copy code

<? Php
$ Mc = new Memcache;
$ Mc-> connect ("127.0.0.1", 11211 );
$ Item = $ mc-> get ('ITEM ');
If (! Is_array ($ item )){
Echo "Add item to memcache ";
$ Mc-> add ('item', array ('ITEM '));
}
$ Item = $ mc-> get ('ITEM ');
Var_dump ($ item );
?>

Finally, we wish you success in improving the server performance and improving website operations.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.