postgres 连接池库
是否有可用于 postgres 连接池的 C/C++ 库?我研究过 pgpool,它更像是一个中间件。我正在寻找一个可以编码到我的应用程序中的库。
Is any C/C++ library available for postgres connection pooling? I have looked at pgpool which is more like a middleware. I am looking for a library which can be coded into my application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您看过 libpqxx 了吗?它本身不是一个连接池,但它提供了一个 C++ API 来从应用程序代码中抽象出连接处理。这允许应用程序非常轻松地构建和管理自己的连接池。
这真的非常简单,这里有一个示例(使用 boost 来实现shared_ptr 和 pqxx)来说明带有工厂方法的池类。您可以想象 runQuery 方法将从指定的池中获取连接,并调用 pqxx API 在底层连接上执行查询。然后它可以将连接返回到池中。
Have you looked at libpqxx yet? It's not a connection pooler per se, however it provides a c++ API to abstract the connection handling from the app code. This allows an app to build and manage its own connection pool quite easily.
It's really pretty simple, here's an example (using boost for shared_ptr & pqxx) to illustrate a pool class, with factory method. You can imagine that the runQuery method would get a connection from the pool specified, and call the pqxx APIs to execute the query on the underlying connection. It can then return the connection to the pool.
没有一个好的应用内连接池库。几乎整个社区都使用外部代理,特别是
pgbouncer
由于其额外的运营效益。与此同时,SOCI 有一个连接池,但它几乎不被用作广泛称为 pgbouncer。There isn't a good in-app connection pooling library. Nearly the entire community uses external proxies, notably
pgbouncer
due to its extra operational benefits. In the same breath, SOCI has a connection pool, but it isn't used nearly as widely aspgbouncer
.