redic 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/redic.rb +5 -0
- data/lib/redic/client.rb +5 -1
- data/redic.gemspec +1 -1
- data/tests/redic_test.rb +11 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a5382b81b79200b8cfb791f454b9089b06ace3b
|
4
|
+
data.tar.gz: 7c893f68df454916127d6b8ef6ab079918745b28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0dc33eb8a5874ceda6f206b880feefd7a1ee7c9614620f95adc0d382fdcd225b0223d95c8865aa738239aa5df73f7328bb5fdb70beb236c18a76c56641b7008
|
7
|
+
data.tar.gz: 5ae3b1abd97cee063cce9d4bdb29ffe2faae66562251533186a9b2016031a287802f3905cbfd6a1ff429278459300f73ec37fd0791d42e3c0d5635d6e421c066
|
data/README.md
CHANGED
@@ -48,6 +48,13 @@ default timeout is 10 seconds.
|
|
48
48
|
redis = Redic.new(REDIS_URL, 2_000_000)
|
49
49
|
redis.timeout == 2_000_000 #=> true
|
50
50
|
```
|
51
|
+
A client can be re-configured, forcing the next connection to
|
52
|
+
be established with the new details:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
redis = Redic.new("redis://localhost:6379")
|
56
|
+
redis.configure("redis://localhost:6380")
|
57
|
+
```
|
51
58
|
|
52
59
|
Here's one final example using both a Redis URL and a timeout:
|
53
60
|
|
@@ -61,6 +68,9 @@ REDIS_TIMEOUT = ENV.fetch("REDIS_TIMEOUT")
|
|
61
68
|
redis = Redic.new(REDIS_URL, REDIS_TIMEOUT)
|
62
69
|
```
|
63
70
|
|
71
|
+
Both the initializer and the `configure` method accept a `URL` and
|
72
|
+
a `timeout`.
|
73
|
+
|
64
74
|
## Differences with redis-rb
|
65
75
|
|
66
76
|
Redic uses [hiredis][hiredis] for the connection and for parsing
|
data/lib/redic.rb
CHANGED
data/lib/redic/client.rb
CHANGED
@@ -6,10 +6,14 @@ class Redic
|
|
6
6
|
attr :timeout
|
7
7
|
|
8
8
|
def initialize(url, timeout)
|
9
|
+
@semaphore = Mutex.new
|
10
|
+
configure(url, timeout)
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(url, timeout)
|
9
14
|
@uri = URI.parse(url)
|
10
15
|
@timeout = timeout
|
11
16
|
@connection = nil
|
12
|
-
@semaphore = Mutex.new
|
13
17
|
end
|
14
18
|
|
15
19
|
def read
|
data/redic.gemspec
CHANGED
data/tests/redic_test.rb
CHANGED
@@ -41,12 +41,12 @@ end
|
|
41
41
|
|
42
42
|
test "error when authenticating from url" do
|
43
43
|
|
44
|
-
# The correct password for
|
45
|
-
c2 = Redic.new("redis://:foo@localhost:
|
44
|
+
# The correct password for 6381 is "foo"
|
45
|
+
c2 = Redic.new("redis://:foo@localhost:6381/")
|
46
46
|
c2.call("PING")
|
47
47
|
|
48
48
|
# The password provided is wrong
|
49
|
-
c3 = Redic.new("redis://:bar@localhost:
|
49
|
+
c3 = Redic.new("redis://:bar@localhost:6381/")
|
50
50
|
|
51
51
|
assert_raise(RuntimeError) do
|
52
52
|
|
@@ -173,3 +173,11 @@ test "pub/sub" do |c1|
|
|
173
173
|
|
174
174
|
assert_equal "PONG", c1.call("PING")
|
175
175
|
end
|
176
|
+
|
177
|
+
test "reconnect" do |c1|
|
178
|
+
assert_equal "6379", c1.call("INFO", "server").slice(/tcp_port:(\d+)/, 1)
|
179
|
+
|
180
|
+
c1.configure("redis://:foo@localhost:6381/")
|
181
|
+
|
182
|
+
assert_equal "6381", c1.call("INFO", "server").slice(/tcp_port:(\d+)/, 1)
|
183
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hiredis
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.0.
|
68
|
+
rubygems_version: 2.0.14
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: Lightweight Redis Client
|