connection_pool 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes.md +5 -0
- data/README.md +19 -5
- data/lib/connection_pool/version.rb +2 -2
- metadata +3 -2
data/Changes.md
CHANGED
data/README.md
CHANGED
@@ -5,11 +5,6 @@ Generic connection pooling for Ruby.
|
|
5
5
|
|
6
6
|
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.
|
7
7
|
|
8
|
-
Requirements
|
9
|
-
--------------
|
10
|
-
|
11
|
-
connection_pool requires Ruby 1.9 because it uses BasicObject.
|
12
|
-
|
13
8
|
|
14
9
|
Install
|
15
10
|
------------
|
@@ -29,6 +24,25 @@ Then use the pool in your application:
|
|
29
24
|
dalli.get('some-count')
|
30
25
|
end
|
31
26
|
|
27
|
+
You can use `ConnectionPool::Wrapper` to wrap a single global connection, making
|
28
|
+
it easier to port your connection code over time:
|
29
|
+
|
30
|
+
$redis = ConnectionPool::Wrapper.new(:size => 5, :timeout => 3) { Redis.connect }
|
31
|
+
$redis.sadd('foo', 1)
|
32
|
+
$redis.smembers('foo')
|
33
|
+
|
34
|
+
The Wrapper uses `method_missing` to checkout a connection, run the
|
35
|
+
requested method and then immediately check the connection back into the
|
36
|
+
pool. It's **not** high-performance so you'll want to port your
|
37
|
+
performance sensitive code to use `with_connection` as soon as possible.
|
38
|
+
|
39
|
+
$redis.with_connection do |conn|
|
40
|
+
conn.sadd('foo', 1)
|
41
|
+
conn.smembers('foo')
|
42
|
+
end
|
43
|
+
|
44
|
+
Once you've ported your entire system to use `with`, you can simply
|
45
|
+
remove ::Wrapper and use a simple, fast ConnectionPool.
|
32
46
|
|
33
47
|
Author
|
34
48
|
--------------
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class ConnectionPool
|
2
|
-
VERSION = "0.9.
|
1
|
+
class ConnectionPool
|
2
|
+
VERSION = "0.9.1"
|
3
3
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: connection_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Generic connection pool for Ruby
|
15
15
|
email:
|
@@ -57,3 +57,4 @@ summary: Generic connection pool for Ruby
|
|
57
57
|
test_files:
|
58
58
|
- test/helper.rb
|
59
59
|
- test/test_connection_pool.rb
|
60
|
+
has_rdoc:
|