Workaround for PHP after Twemproxy cannot delete backend memcache value

Source: Internet
Author: User
Tags phpinfo

The code for PHP operation Memcache is as follows:

[email protected] mc]# cat memcache.php
<?php

$conf = Array (
Array ("host" = ' 192.168.8.57 ', "port" = ' 7522 '),
Array ("host" = ' 192.168.90.130 ', "port" = ' 7510 '),
Array ("host" = ' 192.168.30.22 ', "port" = ' 7011 ')
Array ("host" = ' 192.168.30.23 ', "port" = ' 7030 ')
Array ("host" = ' 192.168.1.61 ', "port" = ' 11211 '),
);
$memcache = new Memcache ();
Memcache_debug (TRUE);
foreach ($conf as $memCachedConfig) {
@ $memcache->addserver ($memCachedConfig [' Host '], $memCachedConfig [' Port '];
}

$STR = "Test";
@ $memcache->set (' TestKey ', $str);
echo $memcache->get (' TestKey ');
echo "\ n";
try{
$rs = $memcache->delete (' TestKey ', 0);
}catch (Exception $e) {
Print_r ($e->getmessage ());
}
Var_dump ($RS);
echo "\ n";
echo $memcache->get (' TestKey ');

#备注: 192.168.8.57 is the virtual IP of Haproxy, the back end points to 192.168.30.21 and 192.168.30.22 two twemproxy, then twemproxy the back end is 192.168.30.21, 192.168.30.22, 192.168.30.23, 192.168.30.24 these 4 memcache

The results that are performed but cannot be deleted are as follows:

[[email protected] mc]# PHP memcache.php
Test
BOOL (FALSE) # #如果删除成功显示的应该是true

The cause of the problem is because PHP memcache extension version is too low, should be a bug in PHP's low version of Memcache, the upgrade can be resolved

Before upgrade:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5C/28/wKiom1UblgHSvBfcAACDKP26Zsg736.jpg "title=" Php2.7.png "alt=" Wkiom1ublghsvbfcaacdkp26zsg736.jpg "/>

After Upgrade:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5C/28/wKiom1UblhaAwxqQAABlSaS1Fdw280.jpg "title=" Php3.0.png "alt=" Wkiom1ublhaawxqqaablsas1fdw280.jpg "/>

Upgrade steps:

wget "Https://pecl.php.net/get/memcache-3.0.8.tgz"

Tar XF memcache-3.0.8.tgz
CD memcache-3.0.8

/usr/local/webserver/php/bin/phpize

./configure--with-php-config=/usr/local/webserver/php/bin/php-config

Make

Make install

/kuxun/php-cgid restart

php-m | grep mem

Ways to view Phpinfo

The Nginx configuration is as follows:

[Email protected] sites-enabled]# vim op.conf

Log_format op_log "$remote _addr"-"$remote _user" [$time _local] "$request"
"$status" "$body _bytes_sent" "$http _referer"
"$http _user_agent", "$http _x_forwarded_for";
server {
Listen 80;
server_name 192.168.90.99;
Set $ROOT _path/home/himalayas/op;

Location/{
#auth_basic "Password";
#auth_basic_user_file/usr/local/webserver/nginx/conf/htpasswd;
Root $ROOT _path;
Index index.php;
}

Location ~. php$ {
Root $ROOT _path;
Fastcgi_pass Unix:/tmp/php-cgi.sock;
Fastcgi_param script_filename $ROOT _path$fastcgi_script_name;
Send_timeout 300;
Fastcgi_buffers 8 256k;
Include/usr/local/webserver/nginx/conf/fastcgi_params;
}

Access_log/home/nginxlog/accesslog/access.log Op_log;
Error_log/home/nginxlog/errorlog/error.log;
}

The code is as follows:

[Email protected] ~]# cat/home/himalayas/op/test.php
<?php
Phpinfo ();
?>

Access method: http://192.168.90.99/test.php

Workaround for PHP after Twemproxy cannot delete backend memcache value

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.