1
0
Fork 0
mirror of https://github.com/mperham/connection_pool synced 2023-03-27 23:22:21 -04:00
This commit is contained in:
Mike Perham 2015-07-27 11:08:50 -07:00
parent 8befd2a4d1
commit 7e0ec9e3b1

View file

@ -45,8 +45,10 @@ sections when a resource is not available, or conversely if you are comfortable
blocking longer on a particular resource. This is not implemented in the below
`ConnectionPool::Wrapper` class.
## Migrating to a Connection Pool
You can use `ConnectionPool::Wrapper` to wrap a single global connection,
making it easier to port your connection code over time:
making it easier to migrate existing connection code over time:
``` ruby
$redis = ConnectionPool::Wrapper.new(size: 5, timeout: 3) { Redis.connect }
@ -69,6 +71,9 @@ end
Once you've ported your entire system to use `with`, you can simply remove
`Wrapper` and use the simpler and faster `ConnectionPool`.
## Shutdown
You can shut down a ConnectionPool instance once it should no longer be used.
Further checkout attempts will immediately raise an error but existing checkouts
will work.
@ -79,7 +84,7 @@ cp.shutdown { |conn| conn.close }
```
Shutting down a connection pool will block until all connections are checked in and closed.
Note that shutting down is completely optional; Ruby's garbage collector will reclaim
**Note that shutting down is completely optional**; Ruby's garbage collector will reclaim
unreferenced pools under normal circumstances.
@ -96,15 +101,6 @@ Notes
exposed by Net::HTTP, Redis, Dalli, etc.
Install
-------
```
$ gem install connection_pool
```
Author
------