最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Memcache not closing connections with close()? - Stack Overflow

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论