Rails Rails 3.2 Automatic closure of connections in threads is deprecated?

ibachue · 2012年04月08日 · 1880 次阅读

Rails 3.2 新特性中有这样一项 引用自 http://edgeguides.rubyonrails.org/3_2_release_notes.html Automatic closure of connections in threads is deprecated. For example the following code is deprecated:

Thread.new { Post.find(1) }.join

It should be changed to close the database connection at the end of the thread:

Thread.new {
  Post.find(1)
  Post.connection.close
}.join

怎么会被改成这样?不理解了。多写句代码,操作不对称,而且数据库的连接向来都是 Rails 管理的,对外透明,现在难道也要开发人员来管理了吗?

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号