redic 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/lib/redic/client.rb +7 -10
- data/redic.gemspec +1 -1
- data/tests/redic_test.rb +14 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e40f39f9e3b3856efa6b485e4d6b15f11756e1f4b21d5871ad17325ec3725d
|
4
|
+
data.tar.gz: 444278b49a7af254e319102a82b7dedfb232056aae792fb929ac4f159e2d534d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79fb3629f83e0fe1d5a0dd27a4d95bf2949a691898b35e10b5e74bcfaeb7039cb3a18e05251c1e2bdf27346e537cb0040d254c4531247db34f3ce96f13ba54dd
|
7
|
+
data.tar.gz: 0065a647b04d3575cf3715829d558ee772f663998f972e8bf55af7e1d58cbf97ac60b02d59c9658939318724835aa3f65fc24384a124fbdc69acec156892c5b2
|
data/CHANGELOG
CHANGED
data/lib/redic/client.rb
CHANGED
@@ -31,14 +31,13 @@ class Redic
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def connect
|
34
|
-
establish_connection unless connected?
|
35
|
-
|
36
34
|
@semaphore.synchronize do
|
35
|
+
establish_connection unless connected?
|
37
36
|
yield
|
37
|
+
rescue Errno::ECONNRESET
|
38
|
+
@connection = false
|
39
|
+
retry
|
38
40
|
end
|
39
|
-
rescue Errno::ECONNRESET
|
40
|
-
@connection = false
|
41
|
-
retry
|
42
41
|
end
|
43
42
|
|
44
43
|
def connected?
|
@@ -54,7 +53,7 @@ class Redic
|
|
54
53
|
|
55
54
|
def quit
|
56
55
|
if connected?
|
57
|
-
assert_ok(call("QUIT"))
|
56
|
+
assert_ok(@semaphore.synchronize { call("QUIT") })
|
58
57
|
disconnect!
|
59
58
|
|
60
59
|
true
|
@@ -83,10 +82,8 @@ class Redic
|
|
83
82
|
end
|
84
83
|
|
85
84
|
def call(*args)
|
86
|
-
|
87
|
-
|
88
|
-
read
|
89
|
-
end
|
85
|
+
write(args)
|
86
|
+
read
|
90
87
|
end
|
91
88
|
|
92
89
|
def assert(value, error)
|
data/redic.gemspec
CHANGED
data/tests/redic_test.rb
CHANGED
@@ -159,6 +159,20 @@ test "thread safety" do |c|
|
|
159
159
|
assert_equal ["2"], bars.uniq
|
160
160
|
end
|
161
161
|
|
162
|
+
test "uses thread safe establishing connecting to avoid sending data to" \
|
163
|
+
"client disconnected by concurrent thread" do |c|
|
164
|
+
c.client.define_singleton_method(:read) do |*otps|
|
165
|
+
sleep 0.1 # make sure that second thread is already waiting on sending data
|
166
|
+
c.client.instance_variable_get(:@connection).disconnect
|
167
|
+
end
|
168
|
+
|
169
|
+
t1 = Thread.new { c.call("GET", "foo") }
|
170
|
+
t2 = Thread.new { c.call("GET", "bar") }
|
171
|
+
|
172
|
+
t1.join
|
173
|
+
t2.join
|
174
|
+
end
|
175
|
+
|
162
176
|
test "blocking commands" do |c1|
|
163
177
|
c2 = Redic.new
|
164
178
|
r = nil
|
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.5.
|
4
|
+
version: 1.5.2
|
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: 2019-
|
12
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hiredis
|
@@ -66,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
|
70
|
-
rubygems_version: 2.7.6
|
69
|
+
rubygems_version: 3.0.2
|
71
70
|
signing_key:
|
72
71
|
specification_version: 4
|
73
72
|
summary: Lightweight Redis Client
|