redis 3.3.5 → 4.0.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/.travis.yml +36 -52
- data/.travis/Gemfile +3 -1
- data/CHANGELOG.md +8 -6
- data/Gemfile +0 -1
- data/README.md +31 -75
- data/benchmarking/logging.rb +1 -1
- data/bors.toml +14 -0
- data/lib/redis.rb +68 -41
- data/lib/redis/client.rb +12 -8
- data/lib/redis/connection.rb +2 -2
- data/lib/redis/connection/command_helper.rb +2 -8
- data/lib/redis/connection/hiredis.rb +2 -2
- data/lib/redis/connection/ruby.rb +8 -28
- data/lib/redis/connection/synchrony.rb +12 -4
- data/lib/redis/distributed.rb +3 -3
- data/lib/redis/hash_ring.rb +20 -64
- data/lib/redis/pipeline.rb +0 -6
- data/lib/redis/version.rb +1 -1
- data/makefile +42 -0
- data/redis.gemspec +7 -9
- data/test/bitpos_test.rb +13 -19
- data/test/blocking_commands_test.rb +3 -5
- data/test/client_test.rb +1 -1
- data/test/command_map_test.rb +3 -5
- data/test/commands_on_hashes_test.rb +2 -4
- data/test/commands_on_hyper_log_log_test.rb +3 -5
- data/test/commands_on_lists_test.rb +2 -4
- data/test/commands_on_sets_test.rb +2 -4
- data/test/commands_on_sorted_sets_test.rb +17 -4
- data/test/commands_on_strings_test.rb +3 -5
- data/test/commands_on_value_types_test.rb +4 -6
- data/test/connection_handling_test.rb +5 -7
- data/test/distributed_blocking_commands_test.rb +2 -4
- data/test/distributed_commands_on_hashes_test.rb +2 -4
- data/test/distributed_commands_on_hyper_log_log_test.rb +2 -4
- data/test/distributed_commands_on_lists_test.rb +2 -4
- data/test/distributed_commands_on_sets_test.rb +2 -4
- data/test/distributed_commands_on_sorted_sets_test.rb +2 -4
- data/test/distributed_commands_on_strings_test.rb +2 -4
- data/test/distributed_commands_on_value_types_test.rb +2 -4
- data/test/distributed_commands_requiring_clustering_test.rb +1 -3
- data/test/distributed_connection_handling_test.rb +1 -3
- data/test/distributed_internals_test.rb +8 -19
- data/test/distributed_key_tags_test.rb +4 -6
- data/test/distributed_persistence_control_commands_test.rb +1 -3
- data/test/distributed_publish_subscribe_test.rb +1 -3
- data/test/distributed_remote_server_control_commands_test.rb +1 -3
- data/test/distributed_scripting_test.rb +1 -3
- data/test/distributed_sorting_test.rb +1 -3
- data/test/distributed_test.rb +12 -14
- data/test/distributed_transactions_test.rb +1 -3
- data/test/encoding_test.rb +4 -8
- data/test/error_replies_test.rb +2 -4
- data/test/fork_safety_test.rb +1 -6
- data/test/helper.rb +10 -41
- data/test/helper_test.rb +1 -3
- data/test/internals_test.rb +67 -55
- data/test/lint/strings.rb +6 -20
- data/test/lint/value_types.rb +8 -0
- data/test/persistence_control_commands_test.rb +1 -3
- data/test/pipelining_commands_test.rb +4 -8
- data/test/publish_subscribe_test.rb +1 -3
- data/test/remote_server_control_commands_test.rb +60 -3
- data/test/scanning_test.rb +1 -7
- data/test/scripting_test.rb +1 -3
- data/test/sentinel_command_test.rb +1 -3
- data/test/sentinel_test.rb +1 -3
- data/test/sorting_test.rb +1 -3
- data/test/ssl_test.rb +45 -49
- data/test/support/connection/hiredis.rb +1 -1
- data/test/support/connection/ruby.rb +1 -1
- data/test/support/connection/synchrony.rb +1 -1
- data/test/synchrony_driver.rb +6 -9
- data/test/thread_safety_test.rb +1 -3
- data/test/transactions_test.rb +1 -3
- data/test/unknown_commands_test.rb +1 -3
- data/test/url_param_test.rb +44 -46
- metadata +30 -18
- data/Rakefile +0 -87
- data/test/connection_test.rb +0 -57
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
4
|
-
require "lint/blocking_commands"
|
1
|
+
require_relative "helper"
|
2
|
+
require_relative "lint/blocking_commands"
|
5
3
|
|
6
4
|
class TestBlockingCommands < Test::Unit::TestCase
|
7
5
|
|
@@ -17,7 +15,7 @@ class TestBlockingCommands < Test::Unit::TestCase
|
|
17
15
|
yield(r)
|
18
16
|
t2 = Time.now
|
19
17
|
|
20
|
-
assert timeout == r.
|
18
|
+
assert timeout == r._client.timeout
|
21
19
|
assert delay <= (t2 - t1)
|
22
20
|
end
|
23
21
|
end
|
data/test/client_test.rb
CHANGED
data/test/command_map_test.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
1
|
+
require_relative "helper"
|
4
2
|
|
5
3
|
class TestCommandMap < Test::Unit::TestCase
|
6
4
|
|
@@ -11,7 +9,7 @@ class TestCommandMap < Test::Unit::TestCase
|
|
11
9
|
|
12
10
|
assert_equal 2, r.incr("counter")
|
13
11
|
|
14
|
-
r.
|
12
|
+
r._client.command_map[:incr] = :decr
|
15
13
|
|
16
14
|
assert_equal 1, r.incr("counter")
|
17
15
|
end
|
@@ -23,7 +21,7 @@ class TestCommandMap < Test::Unit::TestCase
|
|
23
21
|
r.idontexist("key")
|
24
22
|
end
|
25
23
|
|
26
|
-
r.
|
24
|
+
r._client.command_map[:idontexist] = :get
|
27
25
|
|
28
26
|
assert_equal "value", r.idontexist("key")
|
29
27
|
end
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
4
|
-
require "lint/hyper_log_log"
|
1
|
+
require_relative "helper"
|
2
|
+
require_relative "lint/hyper_log_log"
|
5
3
|
|
6
4
|
class TestCommandsOnHyperLogLog < Test::Unit::TestCase
|
7
5
|
|
@@ -18,4 +16,4 @@ class TestCommandsOnHyperLogLog < Test::Unit::TestCase
|
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
|
-
end
|
19
|
+
end
|
@@ -1,13 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
4
|
-
require "lint/sorted_sets"
|
1
|
+
require_relative "helper"
|
2
|
+
require_relative "lint/sorted_sets"
|
5
3
|
|
6
4
|
class TestCommandsOnSortedSets < Test::Unit::TestCase
|
7
5
|
|
8
6
|
include Helper::Client
|
9
7
|
include Lint::SortedSets
|
10
8
|
|
9
|
+
def test_zlexcount
|
10
|
+
target_version "2.8.9" do
|
11
|
+
r.zadd "foo", 0, "aaren"
|
12
|
+
r.zadd "foo", 0, "abagael"
|
13
|
+
r.zadd "foo", 0, "abby"
|
14
|
+
r.zadd "foo", 0, "abbygail"
|
15
|
+
|
16
|
+
assert_equal 4, r.zlexcount("foo", "[a", "[a\xff")
|
17
|
+
assert_equal 4, r.zlexcount("foo", "[aa", "[ab\xff")
|
18
|
+
assert_equal 3, r.zlexcount("foo", "(aaren", "[ab\xff")
|
19
|
+
assert_equal 2, r.zlexcount("foo", "[aba", "(abbygail")
|
20
|
+
assert_equal 1, r.zlexcount("foo", "(aaren", "(abby")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
11
24
|
def test_zrangebylex
|
12
25
|
target_version "2.8.9" do
|
13
26
|
r.zadd "foo", 0, "aaren"
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
4
|
-
require "lint/strings"
|
1
|
+
require_relative "helper"
|
2
|
+
require_relative "lint/strings"
|
5
3
|
|
6
4
|
class TestCommandsOnStrings < Test::Unit::TestCase
|
7
5
|
|
@@ -82,7 +80,7 @@ class TestCommandsOnStrings < Test::Unit::TestCase
|
|
82
80
|
end
|
83
81
|
|
84
82
|
def test_bitop
|
85
|
-
|
83
|
+
with_external_encoding("UTF-8") do
|
86
84
|
target_version "2.5.10" do
|
87
85
|
r.set("foo", "a")
|
88
86
|
r.set("bar", "b")
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
4
|
-
require "lint/value_types"
|
1
|
+
require_relative "helper"
|
2
|
+
require_relative "lint/value_types"
|
5
3
|
|
6
4
|
class TestCommandsOnValueTypes < Test::Unit::TestCase
|
7
5
|
|
@@ -111,8 +109,8 @@ class TestCommandsOnValueTypes < Test::Unit::TestCase
|
|
111
109
|
end
|
112
110
|
assert ex.message =~ /port not specified/
|
113
111
|
|
114
|
-
default_db = redis.
|
115
|
-
default_timeout = redis.
|
112
|
+
default_db = redis._client.db.to_i
|
113
|
+
default_timeout = redis._client.timeout.to_i
|
116
114
|
|
117
115
|
# Test defaults
|
118
116
|
actual = redis.migrate("foo", options)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
1
|
+
require_relative "helper"
|
4
2
|
|
5
3
|
class TestConnectionHandling < Test::Unit::TestCase
|
6
4
|
|
@@ -40,7 +38,7 @@ class TestConnectionHandling < Test::Unit::TestCase
|
|
40
38
|
r.select 14
|
41
39
|
assert_equal nil, r.get("foo")
|
42
40
|
|
43
|
-
r.
|
41
|
+
r._client.disconnect
|
44
42
|
|
45
43
|
assert_equal nil, r.get("foo")
|
46
44
|
end
|
@@ -48,7 +46,7 @@ class TestConnectionHandling < Test::Unit::TestCase
|
|
48
46
|
def test_quit
|
49
47
|
r.quit
|
50
48
|
|
51
|
-
assert !r.
|
49
|
+
assert !r._client.connected?
|
52
50
|
end
|
53
51
|
|
54
52
|
def test_close
|
@@ -148,7 +146,7 @@ class TestConnectionHandling < Test::Unit::TestCase
|
|
148
146
|
end
|
149
147
|
|
150
148
|
assert_equal nil, result
|
151
|
-
assert !redis.
|
149
|
+
assert !redis._client.connected?
|
152
150
|
end
|
153
151
|
end
|
154
152
|
|
@@ -188,7 +186,7 @@ class TestConnectionHandling < Test::Unit::TestCase
|
|
188
186
|
end
|
189
187
|
|
190
188
|
assert_equal nil, result
|
191
|
-
assert !redis.
|
189
|
+
assert !redis._client.connected?
|
192
190
|
end
|
193
191
|
end
|
194
192
|
|
@@ -1,41 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
1
|
+
require_relative "helper"
|
4
2
|
|
5
3
|
class TestDistributedInternals < Test::Unit::TestCase
|
6
4
|
|
7
5
|
include Helper::Distributed
|
8
6
|
|
9
7
|
def test_provides_a_meaningful_inspect
|
10
|
-
nodes = ["redis://
|
8
|
+
nodes = ["redis://127.0.0.1:#{PORT}/15", *NODES]
|
11
9
|
redis = Redis::Distributed.new nodes
|
12
10
|
|
13
11
|
assert_equal "#<Redis client v#{Redis::VERSION} for #{redis.nodes.map(&:id).join(', ')}>", redis.inspect
|
14
12
|
end
|
15
13
|
|
16
14
|
def test_default_as_urls
|
17
|
-
nodes = ["redis://
|
15
|
+
nodes = ["redis://127.0.0.1:#{PORT}/15", *NODES]
|
18
16
|
redis = Redis::Distributed.new nodes
|
19
|
-
assert_equal ["redis://
|
17
|
+
assert_equal ["redis://127.0.0.1:#{PORT}/15", *NODES], redis.nodes.map { |node| node._client.id }
|
20
18
|
end
|
21
19
|
|
22
20
|
def test_default_as_config_hashes
|
23
21
|
nodes = [OPTIONS.merge(:host => '127.0.0.1'), OPTIONS.merge(:host => 'somehost', :port => PORT.next)]
|
24
22
|
redis = Redis::Distributed.new nodes
|
25
|
-
assert_equal ["redis://127.0.0.1:#{PORT}/15","redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node.
|
23
|
+
assert_equal ["redis://127.0.0.1:#{PORT}/15","redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node._client.id }
|
26
24
|
end
|
27
25
|
|
28
26
|
def test_as_mix_and_match
|
29
27
|
nodes = ["redis://127.0.0.1:7389/15", OPTIONS.merge(:host => 'somehost'), OPTIONS.merge(:host => 'somehost', :port => PORT.next)]
|
30
28
|
redis = Redis::Distributed.new nodes
|
31
|
-
assert_equal ["redis://127.0.0.1:7389/15", "redis://somehost:#{PORT}/15", "redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node.
|
29
|
+
assert_equal ["redis://127.0.0.1:7389/15", "redis://somehost:#{PORT}/15", "redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node._client.id }
|
32
30
|
end
|
33
31
|
|
34
32
|
def test_override_id
|
35
33
|
nodes = [OPTIONS.merge(:host => '127.0.0.1', :id => "test"), OPTIONS.merge( :host => 'somehost', :port => PORT.next, :id => "test1")]
|
36
34
|
redis = Redis::Distributed.new nodes
|
37
|
-
assert_equal redis.nodes.first.
|
38
|
-
assert_equal redis.nodes.last.
|
35
|
+
assert_equal redis.nodes.first._client.id, "test"
|
36
|
+
assert_equal redis.nodes.last._client.id, "test1"
|
39
37
|
assert_equal "#<Redis client v#{Redis::VERSION} for #{redis.nodes.map(&:id).join(', ')}>", redis.inspect
|
40
38
|
end
|
41
39
|
|
@@ -67,13 +65,4 @@ class TestDistributedInternals < Test::Unit::TestCase
|
|
67
65
|
|
68
66
|
assert_equal [], r2.sinter("baz:foo", "baz:bar")
|
69
67
|
end
|
70
|
-
|
71
|
-
def test_colliding_node_ids
|
72
|
-
nodes = ["redis://localhost:#{PORT}/15", "redis://localhost:#{PORT}/15", *NODES]
|
73
|
-
|
74
|
-
assert_raise(RuntimeError) do
|
75
|
-
Redis::Distributed.new nodes
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
68
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
1
|
+
require_relative "helper"
|
4
2
|
|
5
3
|
class TestDistributedKeyTags < Test::Unit::TestCase
|
6
4
|
|
@@ -8,9 +6,9 @@ class TestDistributedKeyTags < Test::Unit::TestCase
|
|
8
6
|
include Helper::Distributed
|
9
7
|
|
10
8
|
def test_hashes_consistently
|
11
|
-
r1 = Redis::Distributed.new ["redis://
|
12
|
-
r2 = Redis::Distributed.new ["redis://
|
13
|
-
r3 = Redis::Distributed.new ["redis://
|
9
|
+
r1 = Redis::Distributed.new ["redis://127.0.0.1:#{PORT}/15", *NODES]
|
10
|
+
r2 = Redis::Distributed.new ["redis://127.0.0.1:#{PORT}/15", *NODES]
|
11
|
+
r3 = Redis::Distributed.new ["redis://127.0.0.1:#{PORT}/15", *NODES]
|
14
12
|
|
15
13
|
assert_equal r1.node_for("foo").id, r2.node_for("foo").id
|
16
14
|
assert_equal r1.node_for("foo").id, r3.node_for("foo").id
|