Home > Backend Development > PHP Tutorial > Tencent CMEM PHP extension compilation and installation method_php skills

Tencent CMEM PHP extension compilation and installation method_php skills

WBOY
Release: 2016-05-16 20:07:17
Original
1166 people have browsed it

The example in this article describes the compilation and installation method of PHP extension of Tencent CMEM. Share it with everyone for your reference. The details are as follows:

What is CMEM?

CMEM, the full name of Cloud Memory, is a high-performance memory-level persistent storage service provided by Tencent. It is suitable for scenarios with small data volume, high access volume, and key-value storage.

CMEM is based on a hashmap that stores key/value pairs. Data is stored in memory and ensures data persistence.

What is CMEM PHP Extension?

CMEM is based on the standard Memcached protocol and interface, but only adds return value settings to the data acquisition interface.
Memcached's Get protocol does not have a return code designed, so when the Memcached API returns NO_DATA, it may be caused by network reasons and cannot be fully trusted. Using the following process will be very dangerous and will cause user data to be initialized:

if(NO_DATA) {
  InitData();
}

Copy after login

To solve the above problems, CMEM provides the Memcahced text extension protocol, adding two extended commands get_ext and gets_ext, so that the client can determine whether the data exists based on the return code. This can avoid incorrect initialization of user data due to failure to obtain data when network and device failures occur.

CMEM compilation and installation

# 下载CMEM
cd /home/src
wget http://cmem.googlecode.com/files/cmem-2.2.6.tar.gz
# 解压
tar zxvf cmem-2.2.6.tar.gz
cd cmem-2.2.6
# 编译
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
# 安装PHP扩展
cp modules/cmem.so /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
# 配置php.ini
# 加入以下内容
# --------------------------------------------------
extension = "cmem.so"
# --------------------------------------------------
# 测试
# 新建cmemtest.php
cat > /tmp/cmemtest.php
# 代码为
# --------------------------------------------------
<&#63;php
if(!class_exists('CMEM')) echo "CMEM NOT FOUND!\n";
else echo "CMEM IS OK\n";
&#63;>
# --------------------------------------------------
# 执行测试文件
/usr/local/webserver/php/bin/php -f /tmp/cmemtest.php

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template