To turn long link support on or off, refer to: http://leeon.me/a/php-memcached
Short-chain experimental scenario test code: 1.php
<?PHP$MC = new Memcached (); $mc->setoption (Memcached::opt_libketama_compatible, true); $MC->addservers ( Array ( array (' 10.75.31.39 ', 60000),);p Rint_r ($MC->getstats ()); Sleep (2); >
Long-chain experimental scenario test code: 2.php
<?PHP$MC = new Memcached (' MC '); $MC->setoption (Memcached::opt_libketama_compatible, true); if (!count ($MC Getserverlist ()) { $MC->addservers (Array ( ' 10.75.31.39 ', 60000),) )} Print_r ($MC->getstats ()); Sleep (2); >
Environment:
nginx+phpfpm
PHPFPM static mode, single process.
A experimental process:
1. Access the Curl http://127.0.0.1/1.php, etc. output.
2. When the first step has output, the other window NETSTAT-ANPT | grep:60000.
The conclusion is that each visit will create a new link to the backend resource.
B Experimental Process:
1. Access the Curl http://127.0.0.1/2.php, etc. output.
2. When the first step has output, the other window NETSTAT-ANPT | grep:60000.
The conclusion is that each time you visit, the same link will be created for accessing the backend resources.
Finally, note that even if the request ends, you can still see the 6000-port link until the PHP-FPM process is recycled. Theoretically, idle links are not released.
If you are worried about stepping on a pit, you can add the code to the official Memcached::quit ().
Resources:
http://php.net/manual/zh/memcached.getstats.php
Http://haili.me/archives/530.html
Http://leeon.me/a/php-memcached