doufan6033 2015-06-17 15:42
浏览 21
已采纳

Mgo是否缓存连接字符串?

My Go application has been connecting to a MongoDB (hosted on Compose.io) using MGO with no issues.

Today I decided to delete this database and add a different one (again using Compose). I updated the connection string.

So I connect using:

db, err := mgo.Dial("mongodb://<username>:<password>@dogen.mongohq.com:10048/db-name")

with the username and password in place.

Strangely, the application still appears to connect to the old database. I know this because I printed the err message out which told me: not authorized for query on my-old-db-name after I tried to perform a query.

I have run go install to compile again but still no luck.

  • 写回答

1条回答 默认 最新

  • dongpinyao2203 2015-06-17 16:26
    关注

    No, mgo does not cache the connection strings you give to the mgo.Dial function. It's not even clear to me what that would mean? Using an incorrect database name after you explicitly asked it to connect to a different database would be a serious bug, rather than caching.

    As for your problem, are you sure you are not referring to the old database name inside your own code? The Dial function is not the only way to specify database names (hint: session.DB)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码