redic 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a910a65a110dbb59ba57ac6f9bc012b12b59a1ff
4
- data.tar.gz: 0b0af9cbf96cb99db9d854b1cc491df57afacffe
3
+ metadata.gz: 6b87eca346ba119f79fe0fe1d10d2fddb6496aa8
4
+ data.tar.gz: 0fbf48927126da0626d0e5c7a5b088d2e30e50d1
5
5
  SHA512:
6
- metadata.gz: 44bf2375dedfd7694997dafcf6b6c2202fded203ff330100af7141cf8581680be1381060b9c7e22af90047c9036ebae4a4f1a24cca63fa05728dbefc495d8360
7
- data.tar.gz: 83967139fd09cbce0f1c706b3b4535e376cf880489c362f3252c3e1970303e4413b1a156ca2318b20bc33ab94b578f7a6846116402a9489e0c8db6c7ac3a96af
6
+ metadata.gz: a50d44772e1fb5ae12967fc1bead5b23e01d7c466ab448e7770576e7ac588f2d5eb42f9708d2baa19322bf9e76d0986f79dcb61ef529124a35ca4c0606b37565
7
+ data.tar.gz: d0a00c6821040e8f67441e624b3da6672691d46fbd6abbf1f13f25b7a0510bc09fc9cdc5122482970bc0f60b726c3981701209477b51bcc47f4466c79d62cd55
data/CHANGELOG CHANGED
@@ -1,3 +1,19 @@
1
+ 1.4.1
2
+
3
+ - Reconnect only if URLs differ.
4
+
5
+ 1.4.0
6
+
7
+ - Close connections with Redic#quit.
8
+
9
+ 1.3.0
10
+
11
+ - Improve support for multithreaded environments.
12
+
13
+ 1.2.0
14
+
15
+ - Add Redic#configure.
16
+
1
17
  1.1.1
2
18
 
3
19
  - Redic can now connect to sentinels.
data/README.md CHANGED
@@ -71,6 +71,15 @@ redis = Redic.new(REDIS_URL, REDIS_TIMEOUT)
71
71
  Both the initializer and the `configure` method accept a `URL` and
72
72
  a `timeout`.
73
73
 
74
+ In order to close the connection, call `quit`:
75
+
76
+ ```ruby
77
+ redis = Redic.new("redis://localhost:6379")
78
+ redis.quit
79
+ ```
80
+
81
+ With that command, `"QUIT"` is sent to Redis and the socket is closed.
82
+
74
83
  ## Differences with redis-rb
75
84
 
76
85
  Redic uses [hiredis][hiredis] for the connection and for parsing
@@ -23,8 +23,10 @@ class Redic
23
23
  end
24
24
 
25
25
  def configure(url, timeout = 10_000_000)
26
- @url = url
27
- @client.configure(url, timeout)
26
+ if @url != url
27
+ @url = url
28
+ @client.configure(url, timeout)
29
+ end
28
30
  end
29
31
 
30
32
  def call(*args)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "redic"
5
- s.version = "1.4.0"
5
+ s.version = "1.4.1"
6
6
  s.summary = "Lightweight Redis Client"
7
7
  s.description = "Lightweight Redis Client"
8
8
  s.authors = ["Michel Martens", "Cyril David"]
@@ -4,7 +4,15 @@ require_relative "../lib/redic"
4
4
  REDIS_URL = "redis://localhost:6379/"
5
5
 
6
6
  prepare do
7
- Redic.new(REDIS_URL).call("FLUSHDB")
7
+ c = Redic.new(REDIS_URL)
8
+
9
+ begin
10
+ c.call("FLUSHDB")
11
+ rescue
12
+ c.call("AUTH", "foo")
13
+ c.call("FLUSHDB")
14
+ c.call("CONFIG", "SET", "requirepass", "")
15
+ end
8
16
  end
9
17
 
10
18
  test "multiple threads" do
@@ -5,6 +5,7 @@ REDIS_URL = "redis://localhost:6379/"
5
5
 
6
6
  prepare do
7
7
  c = Redic.new(REDIS_URL)
8
+
8
9
  begin
9
10
  c.call("FLUSHDB")
10
11
  rescue
@@ -187,9 +188,22 @@ test "pub/sub" do |c1|
187
188
  end
188
189
 
189
190
  test "reconnect" do |c1|
191
+ url = "redis://:foo@localhost:6379/"
192
+
193
+ assert url != c1.url
194
+
190
195
  c1.call("CONFIG", "SET", "requirepass", "foo")
191
196
 
192
- c1.configure("redis://:foo@localhost:6379/")
197
+ c1.configure(url)
198
+
199
+ assert url == c1.url
200
+ assert url.object_id == c1.url.object_id
201
+
202
+ # Reconfigure only if URLs differ
203
+ c1.configure(url.dup)
204
+
205
+ # No reconnection ocurred
206
+ assert url.object_id == c1.url.object_id
193
207
 
194
208
  assert_equal "PONG", c1.call("PING")
195
209
  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.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens