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(); }
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 # 代码为 # -------------------------------------------------- <?php if(!class_exists('CMEM')) echo "CMEM NOT FOUND!\n"; else echo "CMEM IS OK\n"; ?> # -------------------------------------------------- # 执行测试文件 /usr/local/webserver/php/bin/php -f /tmp/cmemtest.php
I hope this article will be helpful to everyone’s PHP programming design.