admin管理员组

文章数量:1022843

The below code snippet will show 2 current connections present even after running the close() function.

$memcache = new Memcache;
$memecache->connect('unix:///var/run/memcached/memcached.sock:0'); 
$memecache->close();
$currConnections = $memcache->getExtendedStats()["curr_connections"];
echo $currConnections."<br>";
unset($memcache); 

$memcache = new Memcache;
$memecache->connect('unix:///var/run/memcached/memcached.sock:0'); 
$memecache->close();
$currConnections = $memcache->getExtendedStats()["curr_connections"];
echo $currConnections."<br>";
unset($memcache); 

memcached.sock actually shows 3 connections if I set a breakpoint before the script ends:

echo stats | nc -U /var/run/memcached/memcached.sock | grep "STAT curr_connections"
STAT curr_connections 3

Why is the close() function not closing them immedietaly as the documentation suggests as I am not using persistent connections?

note: I did attempt to use persistent connections but those wouldn't ever close and I would get n*2, where n were n is the number of times I opened the script.

The below code snippet will show 2 current connections present even after running the close() function.

$memcache = new Memcache;
$memecache->connect('unix:///var/run/memcached/memcached.sock:0'); 
$memecache->close();
$currConnections = $memcache->getExtendedStats()["curr_connections"];
echo $currConnections."<br>";
unset($memcache); 

$memcache = new Memcache;
$memecache->connect('unix:///var/run/memcached/memcached.sock:0'); 
$memecache->close();
$currConnections = $memcache->getExtendedStats()["curr_connections"];
echo $currConnections."<br>";
unset($memcache); 

memcached.sock actually shows 3 connections if I set a breakpoint before the script ends:

echo stats | nc -U /var/run/memcached/memcached.sock | grep "STAT curr_connections"
STAT curr_connections 3

Why is the close() function not closing them immedietaly as the documentation suggests as I am not using persistent connections?

note: I did attempt to use persistent connections but those wouldn't ever close and I would get n*2, where n were n is the number of times I opened the script.

本文标签: phpMemcache not closing connections with close()Stack Overflow