redis 3.3.1 → 3.3.5
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/CHANGELOG.md +18 -13
- data/lib/redis.rb +18 -3
- data/lib/redis/client.rb +3 -3
- data/lib/redis/connection/ruby.rb +22 -4
- data/lib/redis/distributed.rb +2 -2
- data/lib/redis/version.rb +1 -1
- data/test/connection_test.rb +57 -0
- data/test/internals_test.rb +0 -40
- data/test/lint/sets.rb +15 -0
- data/test/remote_server_control_commands_test.rb +1 -1
- data/test/ssl_test.rb +7 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 729f56810aa501065e2fc203050363713c80ee37
|
4
|
+
data.tar.gz: e7e13fb75618f794a2c742d73d6c8a72699d5e92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f87e76c751760b7f1feb7c859ea373c41ebf805c104c27e85177cb20a60d42b11c50db2d5a916fb7bfc78b82b13141770a851568aea922ccc1970f4e30ba1dea
|
7
|
+
data.tar.gz: ac4cb236c9c9897d73ead9421e161cf1c7aac2a3c1f77c088b5c52c324cddccda6ab749441093cbcc94ea812e70232f9f9ac1c160a96fd1fbd46d87586d1d7fb
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
# 3.3.5
|
2
|
+
|
3
|
+
* Fixed Ruby 1.8 compatibility after backporting `Redis#connection`. See #719.
|
4
|
+
|
5
|
+
# 3.3.4
|
6
|
+
|
7
|
+
* `Redis#connection` returns a hash with connection information.
|
8
|
+
You shouldn't need to call `Redis#_client`, ever.
|
9
|
+
|
10
|
+
# 3.3.3
|
11
|
+
|
12
|
+
* Improved timeout handling after dropping Timeout module.
|
13
|
+
|
14
|
+
# 3.3.2
|
15
|
+
|
16
|
+
* Added support for SPOP with COUNT. See #628.
|
17
|
+
|
18
|
+
* Fixed connection glitches when using SSL. See #644.
|
14
19
|
|
15
20
|
# 3.3.1
|
16
21
|
|
data/lib/redis.rb
CHANGED
@@ -1336,13 +1336,18 @@ class Redis
|
|
1336
1336
|
end
|
1337
1337
|
end
|
1338
1338
|
|
1339
|
-
# Remove and return
|
1339
|
+
# Remove and return one or more random member from a set.
|
1340
1340
|
#
|
1341
1341
|
# @param [String] key
|
1342
1342
|
# @return [String]
|
1343
|
-
|
1343
|
+
# @param [Fixnum] count
|
1344
|
+
def spop(key, count = nil)
|
1344
1345
|
synchronize do |client|
|
1345
|
-
|
1346
|
+
if count.nil?
|
1347
|
+
client.call([:spop, key])
|
1348
|
+
else
|
1349
|
+
client.call([:spop, key, count])
|
1350
|
+
end
|
1346
1351
|
end
|
1347
1352
|
end
|
1348
1353
|
|
@@ -2695,6 +2700,16 @@ class Redis
|
|
2695
2700
|
self.class.new(@options)
|
2696
2701
|
end
|
2697
2702
|
|
2703
|
+
def connection
|
2704
|
+
{
|
2705
|
+
:host => @original_client.host,
|
2706
|
+
:port => @original_client.port,
|
2707
|
+
:db => @original_client.db,
|
2708
|
+
:id => @original_client.id,
|
2709
|
+
:location => @original_client.location
|
2710
|
+
}
|
2711
|
+
end
|
2712
|
+
|
2698
2713
|
def method_missing(command, *args)
|
2699
2714
|
synchronize do |client|
|
2700
2715
|
client.call([command] + args)
|
data/lib/redis/client.rb
CHANGED
@@ -451,12 +451,12 @@ class Redis
|
|
451
451
|
case options[:tcp_keepalive]
|
452
452
|
when Hash
|
453
453
|
[:time, :intvl, :probes].each do |key|
|
454
|
-
unless options[:tcp_keepalive][key].is_a?(
|
455
|
-
raise "Expected the #{key.inspect} key in :tcp_keepalive to be
|
454
|
+
unless options[:tcp_keepalive][key].is_a?(Integer)
|
455
|
+
raise "Expected the #{key.inspect} key in :tcp_keepalive to be an Integer"
|
456
456
|
end
|
457
457
|
end
|
458
458
|
|
459
|
-
when
|
459
|
+
when Integer
|
460
460
|
if options[:tcp_keepalive] >= 60
|
461
461
|
options[:tcp_keepalive] = {:time => options[:tcp_keepalive] - 20, :intvl => 10, :probes => 2}
|
462
462
|
|
@@ -27,8 +27,13 @@ class Redis
|
|
27
27
|
CRLF = "\r\n".freeze
|
28
28
|
|
29
29
|
# Exceptions raised during non-blocking I/O ops that require retrying the op
|
30
|
-
|
31
|
-
|
30
|
+
if RUBY_VERSION >= "1.9.3"
|
31
|
+
NBIO_READ_EXCEPTIONS = [IO::WaitReadable]
|
32
|
+
NBIO_WRITE_EXCEPTIONS = [IO::WaitWritable]
|
33
|
+
else
|
34
|
+
NBIO_READ_EXCEPTIONS = [Errno::EWOULDBLOCK, Errno::EAGAIN]
|
35
|
+
NBIO_WRITE_EXCEPTIONS = [Errno::EWOULDBLOCK, Errno::EAGAIN]
|
36
|
+
end
|
32
37
|
|
33
38
|
def initialize(*args)
|
34
39
|
super(*args)
|
@@ -78,12 +83,18 @@ class Redis
|
|
78
83
|
begin
|
79
84
|
read_nonblock(nbytes)
|
80
85
|
|
81
|
-
rescue *
|
86
|
+
rescue *NBIO_READ_EXCEPTIONS
|
82
87
|
if IO.select([self], nil, nil, @timeout)
|
83
88
|
retry
|
84
89
|
else
|
85
90
|
raise Redis::TimeoutError
|
86
91
|
end
|
92
|
+
rescue *NBIO_WRITE_EXCEPTIONS
|
93
|
+
if IO.select(nil, [self], nil, @timeout)
|
94
|
+
retry
|
95
|
+
else
|
96
|
+
raise Redis::TimeoutError
|
97
|
+
end
|
87
98
|
end
|
88
99
|
|
89
100
|
rescue EOFError
|
@@ -94,12 +105,18 @@ class Redis
|
|
94
105
|
begin
|
95
106
|
write_nonblock(data)
|
96
107
|
|
97
|
-
rescue *
|
108
|
+
rescue *NBIO_WRITE_EXCEPTIONS
|
98
109
|
if IO.select(nil, [self], nil, @write_timeout)
|
99
110
|
retry
|
100
111
|
else
|
101
112
|
raise Redis::TimeoutError
|
102
113
|
end
|
114
|
+
rescue *NBIO_READ_EXCEPTIONS
|
115
|
+
if IO.select([self], nil, nil, @write_timeout)
|
116
|
+
retry
|
117
|
+
else
|
118
|
+
raise Redis::TimeoutError
|
119
|
+
end
|
103
120
|
end
|
104
121
|
|
105
122
|
rescue EOFError
|
@@ -290,6 +307,7 @@ class Redis
|
|
290
307
|
raise ArgumentError, "SSL incompatible with unix sockets" if config[:ssl]
|
291
308
|
sock = UNIXSocket.connect(config[:path], config[:connect_timeout])
|
292
309
|
elsif config[:scheme] == "rediss" || config[:ssl]
|
310
|
+
raise ArgumentError, "This library does not support SSL on Ruby < 1.9" if RUBY_VERSION < "1.9.3"
|
293
311
|
sock = SSLSocket.connect(config[:host], config[:port], config[:connect_timeout], config[:ssl_params])
|
294
312
|
else
|
295
313
|
sock = TCPSocket.connect(config[:host], config[:port], config[:connect_timeout])
|
data/lib/redis/distributed.rb
CHANGED
data/lib/redis/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
|
3
|
+
class TestConnection < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include Helper::Client
|
6
|
+
|
7
|
+
def test_provides_a_meaningful_inspect
|
8
|
+
assert_equal "#<Redis client v#{Redis::VERSION} for redis://127.0.0.1:#{PORT}/15>", r.inspect
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_connection_information
|
12
|
+
assert_equal "127.0.0.1", r.connection.fetch(:host)
|
13
|
+
assert_equal 6381, r.connection.fetch(:port)
|
14
|
+
assert_equal 15, r.connection.fetch(:db)
|
15
|
+
assert_equal "127.0.0.1:6381", r.connection.fetch(:location)
|
16
|
+
assert_equal "redis://127.0.0.1:6381/15", r.connection.fetch(:id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_default_id_with_host_and_port
|
20
|
+
redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0))
|
21
|
+
assert_equal "redis://host:1234/0", redis.connection.fetch(:id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_default_id_with_host_and_port_and_explicit_scheme
|
25
|
+
redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0, :scheme => "foo"))
|
26
|
+
assert_equal "redis://host:1234/0", redis.connection.fetch(:id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_default_id_with_path
|
30
|
+
redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0))
|
31
|
+
assert_equal "redis:///tmp/redis.sock/0", redis.connection.fetch(:id)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_default_id_with_path_and_explicit_scheme
|
35
|
+
redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0, :scheme => "foo"))
|
36
|
+
assert_equal "redis:///tmp/redis.sock/0", redis.connection.fetch(:id)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_override_id
|
40
|
+
redis = Redis.new(OPTIONS.merge(:id => "test"))
|
41
|
+
assert_equal "test", redis.connection.fetch(:id)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_id_inside_multi
|
45
|
+
redis = Redis.new(OPTIONS)
|
46
|
+
id = nil
|
47
|
+
connection_id = nil
|
48
|
+
|
49
|
+
redis.multi do
|
50
|
+
id = redis.id
|
51
|
+
connection_id = redis.connection.fetch(:id)
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal "redis://127.0.0.1:6381/15", id
|
55
|
+
assert_equal "redis://127.0.0.1:6381/15", connection_id
|
56
|
+
end
|
57
|
+
end
|
data/test/internals_test.rb
CHANGED
@@ -44,10 +44,6 @@ class TestInternals < Test::Unit::TestCase
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def test_provides_a_meaningful_inspect
|
48
|
-
assert_equal "#<Redis client v#{Redis::VERSION} for redis://127.0.0.1:#{PORT}/15>", r.inspect
|
49
|
-
end
|
50
|
-
|
51
47
|
def test_redis_current
|
52
48
|
assert_equal "127.0.0.1", Redis.current.client.host
|
53
49
|
assert_equal 6379, Redis.current.client.port
|
@@ -79,48 +75,12 @@ class TestInternals < Test::Unit::TestCase
|
|
79
75
|
assert !fresh_client.connected?
|
80
76
|
end
|
81
77
|
|
82
|
-
def test_default_id_with_host_and_port
|
83
|
-
redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0))
|
84
|
-
assert_equal "redis://host:1234/0", redis.client.id
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_default_id_with_host_and_port_and_explicit_scheme
|
88
|
-
redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0, :scheme => "foo"))
|
89
|
-
assert_equal "redis://host:1234/0", redis.client.id
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_default_id_with_path
|
93
|
-
redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0))
|
94
|
-
assert_equal "redis:///tmp/redis.sock/0", redis.client.id
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_default_id_with_path_and_explicit_scheme
|
98
|
-
redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0, :scheme => "foo"))
|
99
|
-
assert_equal "redis:///tmp/redis.sock/0", redis.client.id
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_override_id
|
103
|
-
redis = Redis.new(OPTIONS.merge(:id => "test"))
|
104
|
-
assert_equal redis.client.id, "test"
|
105
|
-
end
|
106
|
-
|
107
78
|
def test_timeout
|
108
79
|
assert_nothing_raised do
|
109
80
|
Redis.new(OPTIONS.merge(:timeout => 0))
|
110
81
|
end
|
111
82
|
end
|
112
83
|
|
113
|
-
def test_id_inside_multi
|
114
|
-
redis = Redis.new(OPTIONS)
|
115
|
-
id = nil
|
116
|
-
|
117
|
-
redis.multi do
|
118
|
-
id = redis.id
|
119
|
-
end
|
120
|
-
|
121
|
-
assert_equal id, "redis://127.0.0.1:6381/15"
|
122
|
-
end
|
123
|
-
|
124
84
|
driver(:ruby) do
|
125
85
|
def test_tcp_keepalive
|
126
86
|
keepalive = {:time => 20, :intvl => 10, :probes => 5}
|
data/test/lint/sets.rb
CHANGED
@@ -52,6 +52,21 @@ module Lint
|
|
52
52
|
assert_equal nil, r.spop("foo")
|
53
53
|
end
|
54
54
|
|
55
|
+
def test_spop_with_positive_count
|
56
|
+
target_version "3.2.0" do
|
57
|
+
r.sadd "foo", "s1"
|
58
|
+
r.sadd "foo", "s2"
|
59
|
+
r.sadd "foo", "s3"
|
60
|
+
r.sadd "foo", "s4"
|
61
|
+
|
62
|
+
pops = r.spop("foo", 3)
|
63
|
+
|
64
|
+
assert !(["s1", "s2", "s3", "s4"] & pops).empty?
|
65
|
+
assert_equal 3, pops.size
|
66
|
+
assert_equal 1, r.scard("foo")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
55
70
|
def test_scard
|
56
71
|
assert_equal 0, r.scard("foo")
|
57
72
|
|
@@ -101,7 +101,7 @@ class TestRemoteServerControlCommands < Test::Unit::TestCase
|
|
101
101
|
assert_equal 1, r.object(:refcount, "list")
|
102
102
|
encoding = r.object(:encoding, "list")
|
103
103
|
assert "ziplist" == encoding || "quicklist" == encoding, "Wrong encoding for list"
|
104
|
-
assert r.object(:idletime, "list").kind_of?(
|
104
|
+
assert r.object(:idletime, "list").kind_of?(Integer)
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_sync
|
data/test/ssl_test.rb
CHANGED
@@ -25,6 +25,13 @@ if RUBY_VERSION >= "1.9.3"
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_ssl_blocking
|
29
|
+
RedisMock.start({}, ssl_server_opts("trusted")) do |port|
|
30
|
+
redis = Redis.new(:port => port, :ssl => true, :ssl_params => { :ca_file => ssl_ca_file })
|
31
|
+
assert_equal redis.set("boom", "a" * 10_000_000), "OK"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
28
35
|
end
|
29
36
|
|
30
37
|
driver(:hiredis, :synchrony) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Zygmuntowicz
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date:
|
19
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: rake
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- test/commands_on_strings_test.rb
|
110
110
|
- test/commands_on_value_types_test.rb
|
111
111
|
- test/connection_handling_test.rb
|
112
|
+
- test/connection_test.rb
|
112
113
|
- test/db/.gitkeep
|
113
114
|
- test/distributed_blocking_commands_test.rb
|
114
115
|
- test/distributed_commands_on_hashes_test.rb
|
@@ -211,6 +212,7 @@ test_files:
|
|
211
212
|
- test/commands_on_strings_test.rb
|
212
213
|
- test/commands_on_value_types_test.rb
|
213
214
|
- test/connection_handling_test.rb
|
215
|
+
- test/connection_test.rb
|
214
216
|
- test/db/.gitkeep
|
215
217
|
- test/distributed_blocking_commands_test.rb
|
216
218
|
- test/distributed_commands_on_hashes_test.rb
|