开发者社区> 问答> 正文

mongodb连接没释放的问题

按照php的话 会自动释放连接 但是就是有好多 即使php运行完毕也没被释放 为什么?
php官方http://www.php.net/manual/en/mongo.close.php
中介绍 public bool Mongo::close ( void )
This method does not need to be called, except in unusual circumstances. The driver will cleanly close the database connection when this Mongo instance goes out of scope.

If objects do not go out of scope between requests, you may wish to call this method at the end of your program to keep old connections from hanging around. However, it is probably more efficient use a persistent connection, which will automatically create a connection if needed and use it for as many requests as possible.

If you are connected to a replica set, close() will only close the connection to the primary.
不需要调用关闭。那要如何做,求指导。

展开
收起
落地花开啦 2016-02-05 17:34:10 3802 0
1 条回答
写回答
取消 提交回答
  • 喜欢技术,喜欢努力的人

    用长连接
    同时代码释放连接!

    2019-07-17 18:37:59
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Data as a Service - 数据即服务 -- MongoDB⾼级应⽤模式 立即下载
阿里云MongoDB云服务构建 立即下载
饿了么高级架构师陈东明:MongoDB是如何逐步提高可靠性的 立即下载