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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +36 -52
  3. data/.travis/Gemfile +3 -1
  4. data/CHANGELOG.md +8 -6
  5. data/Gemfile +0 -1
  6. data/README.md +31 -75
  7. data/benchmarking/logging.rb +1 -1
  8. data/bors.toml +14 -0
  9. data/lib/redis.rb +68 -41
  10. data/lib/redis/client.rb +12 -8
  11. data/lib/redis/connection.rb +2 -2
  12. data/lib/redis/connection/command_helper.rb +2 -8
  13. data/lib/redis/connection/hiredis.rb +2 -2
  14. data/lib/redis/connection/ruby.rb +8 -28
  15. data/lib/redis/connection/synchrony.rb +12 -4
  16. data/lib/redis/distributed.rb +3 -3
  17. data/lib/redis/hash_ring.rb +20 -64
  18. data/lib/redis/pipeline.rb +0 -6
  19. data/lib/redis/version.rb +1 -1
  20. data/makefile +42 -0
  21. data/redis.gemspec +7 -9
  22. data/test/bitpos_test.rb +13 -19
  23. data/test/blocking_commands_test.rb +3 -5
  24. data/test/client_test.rb +1 -1
  25. data/test/command_map_test.rb +3 -5
  26. data/test/commands_on_hashes_test.rb +2 -4
  27. data/test/commands_on_hyper_log_log_test.rb +3 -5
  28. data/test/commands_on_lists_test.rb +2 -4
  29. data/test/commands_on_sets_test.rb +2 -4
  30. data/test/commands_on_sorted_sets_test.rb +17 -4
  31. data/test/commands_on_strings_test.rb +3 -5
  32. data/test/commands_on_value_types_test.rb +4 -6
  33. data/test/connection_handling_test.rb +5 -7
  34. data/test/distributed_blocking_commands_test.rb +2 -4
  35. data/test/distributed_commands_on_hashes_test.rb +2 -4
  36. data/test/distributed_commands_on_hyper_log_log_test.rb +2 -4
  37. data/test/distributed_commands_on_lists_test.rb +2 -4
  38. data/test/distributed_commands_on_sets_test.rb +2 -4
  39. data/test/distributed_commands_on_sorted_sets_test.rb +2 -4
  40. data/test/distributed_commands_on_strings_test.rb +2 -4
  41. data/test/distributed_commands_on_value_types_test.rb +2 -4
  42. data/test/distributed_commands_requiring_clustering_test.rb +1 -3
  43. data/test/distributed_connection_handling_test.rb +1 -3
  44. data/test/distributed_internals_test.rb +8 -19
  45. data/test/distributed_key_tags_test.rb +4 -6
  46. data/test/distributed_persistence_control_commands_test.rb +1 -3
  47. data/test/distributed_publish_subscribe_test.rb +1 -3
  48. data/test/distributed_remote_server_control_commands_test.rb +1 -3
  49. data/test/distributed_scripting_test.rb +1 -3
  50. data/test/distributed_sorting_test.rb +1 -3
  51. data/test/distributed_test.rb +12 -14
  52. data/test/distributed_transactions_test.rb +1 -3
  53. data/test/encoding_test.rb +4 -8
  54. data/test/error_replies_test.rb +2 -4
  55. data/test/fork_safety_test.rb +1 -6
  56. data/test/helper.rb +10 -41
  57. data/test/helper_test.rb +1 -3
  58. data/test/internals_test.rb +67 -55
  59. data/test/lint/strings.rb +6 -20
  60. data/test/lint/value_types.rb +8 -0
  61. data/test/persistence_control_commands_test.rb +1 -3
  62. data/test/pipelining_commands_test.rb +4 -8
  63. data/test/publish_subscribe_test.rb +1 -3
  64. data/test/remote_server_control_commands_test.rb +60 -3
  65. data/test/scanning_test.rb +1 -7
  66. data/test/scripting_test.rb +1 -3
  67. data/test/sentinel_command_test.rb +1 -3
  68. data/test/sentinel_test.rb +1 -3
  69. data/test/sorting_test.rb +1 -3
  70. data/test/ssl_test.rb +45 -49
  71. data/test/support/connection/hiredis.rb +1 -1
  72. data/test/support/connection/ruby.rb +1 -1
  73. data/test/support/connection/synchrony.rb +1 -1
  74. data/test/synchrony_driver.rb +6 -9
  75. data/test/thread_safety_test.rb +1 -3
  76. data/test/transactions_test.rb +1 -3
  77. data/test/unknown_commands_test.rb +1 -3
  78. data/test/url_param_test.rb +44 -46
  79. metadata +30 -18
  80. data/Rakefile +0 -87
  81. data/test/connection_test.rb +0 -57
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
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.client.timeout
18
+ assert timeout == r._client.timeout
21
19
  assert delay <= (t2 - t1)
22
20
  end
23
21
  end
data/test/client_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
2
2
 
3
3
  class TestClient < Test::Unit::TestCase
4
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
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.client.command_map[:incr] = :decr
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.client.command_map[:idontexist] = :get
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
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/hashes"
1
+ require_relative "helper"
2
+ require_relative "lint/hashes"
5
3
 
6
4
  class TestCommandsOnHashes < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
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,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/lists"
1
+ require_relative "helper"
2
+ require_relative "lint/lists"
5
3
 
6
4
  class TestCommandsOnLists < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/sets"
1
+ require_relative "helper"
2
+ require_relative "lint/sets"
5
3
 
6
4
  class TestCommandsOnSets < Test::Unit::TestCase
7
5
 
@@ -1,13 +1,26 @@
1
- # encoding: UTF-8
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
- # encoding: UTF-8
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
- try_encoding("UTF-8") do
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
- # encoding: UTF-8
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.client.db.to_i
115
- default_timeout = redis.client.timeout.to_i
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
- # encoding: UTF-8
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.client.disconnect
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.client.connected?
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.client.connected?
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.client.connected?
189
+ assert !redis._client.connected?
192
190
  end
193
191
  end
194
192
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
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 TestDistributedBlockingCommands < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/hashes"
1
+ require_relative "helper"
2
+ require_relative "lint/hashes"
5
3
 
6
4
  class TestDistributedCommandsOnHashes < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
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 TestDistributedCommandsOnHyperLogLog < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/lists"
1
+ require_relative "helper"
2
+ require_relative "lint/lists"
5
3
 
6
4
  class TestDistributedCommandsOnLists < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/sets"
1
+ require_relative "helper"
2
+ require_relative "lint/sets"
5
3
 
6
4
  class TestDistributedCommandsOnSets < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
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 TestDistributedCommandsOnSortedSets < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
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 TestDistributedCommandsOnStrings < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
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 TestDistributedCommandsOnValueTypes < Test::Unit::TestCase
7
5
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedCommandsRequiringClustering < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedConnectionHandling < Test::Unit::TestCase
6
4
 
@@ -1,41 +1,39 @@
1
- # encoding: UTF-8
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://localhost:#{PORT}/15", *NODES]
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://localhost:#{PORT}/15", *NODES]
15
+ nodes = ["redis://127.0.0.1:#{PORT}/15", *NODES]
18
16
  redis = Redis::Distributed.new nodes
19
- assert_equal ["redis://localhost:#{PORT}/15", *NODES], redis.nodes.map { |node| node.client.id}
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.client.id }
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.client.id }
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.client.id, "test"
38
- assert_equal redis.nodes.last.client.id, "test1"
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
- # encoding: UTF-8
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://localhost:#{PORT}/15", *NODES]
12
- r2 = Redis::Distributed.new ["redis://localhost:#{PORT}/15", *NODES]
13
- r3 = Redis::Distributed.new ["redis://localhost:#{PORT}/15", *NODES]
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
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedPersistenceControlCommands < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedPublishSubscribe < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedRemoteServerControlCommands < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedScripting < Test::Unit::TestCase
6
4