1
0
Fork 0
mirror of https://github.com/mperham/connection_pool synced 2023-03-27 23:22:21 -04:00
Generic connection pooling for Ruby
Find a file
2011-05-14 15:36:17 -07:00
lib Add project info, tests 2011-05-14 15:36:17 -07:00
test Add project info, tests 2011-05-14 15:36:17 -07:00
.gitignore Initial pass at a generic connection pool 2011-05-14 12:29:51 -07:00
connection_pool.gemspec Initial pass at a generic connection pool 2011-05-14 12:29:51 -07:00
Gemfile Add project info, tests 2011-05-14 15:36:17 -07:00
LICENSE Add project info, tests 2011-05-14 15:36:17 -07:00
Rakefile Add project info, tests 2011-05-14 15:36:17 -07:00
README.md Add project info, tests 2011-05-14 15:36:17 -07:00

connection_pool

Generic connection pooling for Ruby.

MongoDB has its own connection pool. ActiveRecord has its own connection pool. This is a generic connection pool that can be used with anything, e.g. Redis, Dalli and other Ruby network clients.

Install

gem install connection_pool

Usage

Create a pool of objects to share amongst the fibers or threads in your Ruby application:

@memcached = ConnectionPool.new(:size => 5, :timeout => 5) { Dalli::Client.new }

Then use the pool in your application:

@memcached.with do |dalli|
  dalli.fetch('some-count', :expires_in => 1.day) do
    SomeModel.query.count
  end
end

Author

Mike Perham, @mperham, http://mikeperham.com