Skip to content

Instantly share code, notes, and snippets.

@nicksieger
Created August 29, 2008 19:47
Show Gist options
  • Save nicksieger/8041 to your computer and use it in GitHub Desktop.
Save nicksieger/8041 to your computer and use it in GitHub Desktop.
Database connections are now pooled, one pool per #establish_connection call.
Pools start out empty and grow as necessary to a maximum size (default is 5,
configure size with key 'pool' in your database configuration). If no
connections are available, a thread will wait up to a 'wait_timeout' time
(default is 5 seconds).
Connections are verified and reset when checked out from the pool (usually
upon first access to ActiveRecord::Base.connection), and returned back to the
pool after each request.
If you would like to use connection pools outside of ActionPack, there is an
ActiveRecord::Base.connection_pool method that gives you access to the pool,
and you can manually checkout/checkin connections, or supply a block to
ActiveRecord::Base.connection_pool.with_connection which takes care of the
checkout/checkin for you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment