diff options
author | Vipul A M <vipulnsward@gmail.com> | 2016-04-24 16:22:13 +0530 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-24 13:28:48 -0700 |
commit | 6c6eeda54d0f2c8e689772b50cc5c4419fa82749 (patch) | |
tree | db0990c7e2bbd5da3d6d20844a1f543c58defdff /activerecord/lib/active_record/connection_adapters/statement_pool.rb | |
parent | 7463aa19b1a1492bcc6aeb61e3163a893856453c (diff) | |
download | rails-6c6eeda54d0f2c8e689772b50cc5c4419fa82749.tar.gz rails-6c6eeda54d0f2c8e689772b50cc5c4419fa82749.tar.bz2 rails-6c6eeda54d0f2c8e689772b50cc5c4419fa82749.zip |
Follow up of #23461
- Rename max to statement_limit
- Remove magic number 1000 from everywhere
- Defined StatementPool::DEFAULT_STATEMENT_LIMIT and started using it everywhere
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/statement_pool.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/statement_pool.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/statement_pool.rb b/activerecord/lib/active_record/connection_adapters/statement_pool.rb index dcd96d9899..9b0ed3e08b 100644 --- a/activerecord/lib/active_record/connection_adapters/statement_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/statement_pool.rb @@ -3,9 +3,11 @@ module ActiveRecord class StatementPool # :nodoc: include Enumerable - def initialize(max = 1000) + DEFAULT_STATEMENT_LIMIT = 1000 + + def initialize(statement_limit = nil) @cache = Hash.new { |h,pid| h[pid] = {} } - @max = max + @statement_limit = statement_limit || DEFAULT_STATEMENT_LIMIT end def each(&block) @@ -25,7 +27,7 @@ module ActiveRecord end def []=(sql, stmt) - while @max <= cache.size + while @statement_limit <= cache.size dealloc(cache.shift.last) end cache[sql] = stmt |