2011-05-14 18:36:17 -04: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.
2011-09-19 13:29:31 -04:00
Requirements
--------------
connection_pool requires Ruby 1.9 because it uses BasicObject.
2011-05-14 18:36:17 -04:00
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:
2011-05-14 22:42:07 -04:00
@memcached .with_connection do |dalli|
dalli.get('some-count')
2011-05-14 18:36:17 -04:00
end
Author
--------------
2011-09-19 13:29:31 -04:00
Mike Perham, [@mperham ](https://twitter.com/mperham ), < http: // mikeperham . com >