问题描述
所以我试图在Rails 3.2.8应用程序中使用datamapper。
So I am trying to use datamapper inside my Rails 3.2.8 app.
我有一个 config / initializers / dm.rb
我在其中加载 database.yml
I have a config/initializers/dm.rb
where I load the database.yml
hash = YAML.load(File.new("database.yml"))
DataMapper.setup(:default, hash[Rails.env])
我在database.yml文件中设置了 pool
属性,但是我注意到datamapper不使用它。它使用了这个神奇的数字 8
,这个数字来自哪里?以及如何为datamapper配置池设置。
I have a pool
property set in the database.yml file, but I noticed that datamapper does not use that. It has this magic number 8
which it uses, where is this number coming from? And how can I configure pool settings for datamapper.
推荐答案
恰好在DataMapper.finalize之后,将其添加到我的测试中(使用'sqlite3 :: memory:')将池大小减小为1
just after DataMapper.finalize I add this for my tests ( with 'sqlite3::memory:' ) to reduce the poolsize to 1
class DataObjects::Pooling::Pool
alias :initialize_old :initialize
def initialize(max_size, resource, args)
initialize_old( 1, resource, args)
end
end
这篇关于数据映射器连接池逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!