请问beego下面连接MongoDB怎么做?

是使用gopkg.in/mgo.v2 这个吗?


怎么在项目里面使用mgo的连接池?


谢谢

已邀请:

jinheking

赞同来自:

谢谢,我使用的就是这个第三方库。但是,不知道有没有连接池

tupunco

赞同来自:

@jinheking 你如果认真阅读了这个项目的 godoc 就不会问有没有 连接池 问题了.


// New sessions are typically created by calling session.Copy on the
// initial session obtained at dial time. `These new sessions will share
// the same cluster information and connection pool`, and may be easily
// handed into other methods and functions for organizing logic.
// Every session created must have its Close method called at the end
// of its life time, so its resources may be put back in the pool or
// collected, depending on the case.

https://github.com/go-mgo/mgo/blob/v2/doc.go#L21

jinheking

赞同来自:

谢谢,我虽然没有看这个说明,但是我却使用了这个方法,谢谢。再次感谢。

要回复问题请先登录注册