redis 3.3.5 → 4.3.1

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 (130) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +132 -2
  3. data/README.md +144 -79
  4. data/lib/redis.rb +1174 -405
  5. data/lib/redis/client.rb +150 -90
  6. data/lib/redis/cluster.rb +295 -0
  7. data/lib/redis/cluster/command.rb +81 -0
  8. data/lib/redis/cluster/command_loader.rb +34 -0
  9. data/lib/redis/cluster/key_slot_converter.rb +72 -0
  10. data/lib/redis/cluster/node.rb +107 -0
  11. data/lib/redis/cluster/node_key.rb +31 -0
  12. data/lib/redis/cluster/node_loader.rb +37 -0
  13. data/lib/redis/cluster/option.rb +93 -0
  14. data/lib/redis/cluster/slot.rb +86 -0
  15. data/lib/redis/cluster/slot_loader.rb +49 -0
  16. data/lib/redis/connection.rb +4 -2
  17. data/lib/redis/connection/command_helper.rb +5 -10
  18. data/lib/redis/connection/hiredis.rb +6 -5
  19. data/lib/redis/connection/registry.rb +2 -1
  20. data/lib/redis/connection/ruby.rb +126 -128
  21. data/lib/redis/connection/synchrony.rb +21 -8
  22. data/lib/redis/distributed.rb +147 -72
  23. data/lib/redis/errors.rb +48 -0
  24. data/lib/redis/hash_ring.rb +30 -73
  25. data/lib/redis/pipeline.rb +55 -15
  26. data/lib/redis/subscribe.rb +11 -12
  27. data/lib/redis/version.rb +3 -1
  28. metadata +49 -202
  29. data/.gitignore +0 -16
  30. data/.travis.yml +0 -89
  31. data/.travis/Gemfile +0 -11
  32. data/.yardopts +0 -3
  33. data/Gemfile +0 -4
  34. data/Rakefile +0 -87
  35. data/benchmarking/logging.rb +0 -71
  36. data/benchmarking/pipeline.rb +0 -51
  37. data/benchmarking/speed.rb +0 -21
  38. data/benchmarking/suite.rb +0 -24
  39. data/benchmarking/worker.rb +0 -71
  40. data/examples/basic.rb +0 -15
  41. data/examples/consistency.rb +0 -114
  42. data/examples/dist_redis.rb +0 -43
  43. data/examples/incr-decr.rb +0 -17
  44. data/examples/list.rb +0 -26
  45. data/examples/pubsub.rb +0 -37
  46. data/examples/sentinel.rb +0 -41
  47. data/examples/sentinel/sentinel.conf +0 -9
  48. data/examples/sentinel/start +0 -49
  49. data/examples/sets.rb +0 -36
  50. data/examples/unicorn/config.ru +0 -3
  51. data/examples/unicorn/unicorn.rb +0 -20
  52. data/redis.gemspec +0 -44
  53. data/test/bitpos_test.rb +0 -69
  54. data/test/blocking_commands_test.rb +0 -42
  55. data/test/client_test.rb +0 -59
  56. data/test/command_map_test.rb +0 -30
  57. data/test/commands_on_hashes_test.rb +0 -21
  58. data/test/commands_on_hyper_log_log_test.rb +0 -21
  59. data/test/commands_on_lists_test.rb +0 -20
  60. data/test/commands_on_sets_test.rb +0 -77
  61. data/test/commands_on_sorted_sets_test.rb +0 -137
  62. data/test/commands_on_strings_test.rb +0 -101
  63. data/test/commands_on_value_types_test.rb +0 -133
  64. data/test/connection_handling_test.rb +0 -277
  65. data/test/connection_test.rb +0 -57
  66. data/test/db/.gitkeep +0 -0
  67. data/test/distributed_blocking_commands_test.rb +0 -46
  68. data/test/distributed_commands_on_hashes_test.rb +0 -10
  69. data/test/distributed_commands_on_hyper_log_log_test.rb +0 -33
  70. data/test/distributed_commands_on_lists_test.rb +0 -22
  71. data/test/distributed_commands_on_sets_test.rb +0 -83
  72. data/test/distributed_commands_on_sorted_sets_test.rb +0 -18
  73. data/test/distributed_commands_on_strings_test.rb +0 -59
  74. data/test/distributed_commands_on_value_types_test.rb +0 -95
  75. data/test/distributed_commands_requiring_clustering_test.rb +0 -164
  76. data/test/distributed_connection_handling_test.rb +0 -23
  77. data/test/distributed_internals_test.rb +0 -79
  78. data/test/distributed_key_tags_test.rb +0 -52
  79. data/test/distributed_persistence_control_commands_test.rb +0 -26
  80. data/test/distributed_publish_subscribe_test.rb +0 -92
  81. data/test/distributed_remote_server_control_commands_test.rb +0 -66
  82. data/test/distributed_scripting_test.rb +0 -102
  83. data/test/distributed_sorting_test.rb +0 -20
  84. data/test/distributed_test.rb +0 -58
  85. data/test/distributed_transactions_test.rb +0 -32
  86. data/test/encoding_test.rb +0 -18
  87. data/test/error_replies_test.rb +0 -59
  88. data/test/fork_safety_test.rb +0 -65
  89. data/test/helper.rb +0 -232
  90. data/test/helper_test.rb +0 -24
  91. data/test/internals_test.rb +0 -417
  92. data/test/lint/blocking_commands.rb +0 -150
  93. data/test/lint/hashes.rb +0 -162
  94. data/test/lint/hyper_log_log.rb +0 -60
  95. data/test/lint/lists.rb +0 -143
  96. data/test/lint/sets.rb +0 -140
  97. data/test/lint/sorted_sets.rb +0 -316
  98. data/test/lint/strings.rb +0 -260
  99. data/test/lint/value_types.rb +0 -122
  100. data/test/persistence_control_commands_test.rb +0 -26
  101. data/test/pipelining_commands_test.rb +0 -242
  102. data/test/publish_subscribe_test.rb +0 -282
  103. data/test/remote_server_control_commands_test.rb +0 -118
  104. data/test/scanning_test.rb +0 -413
  105. data/test/scripting_test.rb +0 -78
  106. data/test/sentinel_command_test.rb +0 -80
  107. data/test/sentinel_test.rb +0 -255
  108. data/test/sorting_test.rb +0 -59
  109. data/test/ssl_test.rb +0 -73
  110. data/test/support/connection/hiredis.rb +0 -1
  111. data/test/support/connection/ruby.rb +0 -1
  112. data/test/support/connection/synchrony.rb +0 -17
  113. data/test/support/redis_mock.rb +0 -130
  114. data/test/support/ssl/gen_certs.sh +0 -31
  115. data/test/support/ssl/trusted-ca.crt +0 -25
  116. data/test/support/ssl/trusted-ca.key +0 -27
  117. data/test/support/ssl/trusted-cert.crt +0 -81
  118. data/test/support/ssl/trusted-cert.key +0 -28
  119. data/test/support/ssl/untrusted-ca.crt +0 -26
  120. data/test/support/ssl/untrusted-ca.key +0 -27
  121. data/test/support/ssl/untrusted-cert.crt +0 -82
  122. data/test/support/ssl/untrusted-cert.key +0 -28
  123. data/test/support/wire/synchrony.rb +0 -24
  124. data/test/support/wire/thread.rb +0 -5
  125. data/test/synchrony_driver.rb +0 -88
  126. data/test/test.conf.erb +0 -9
  127. data/test/thread_safety_test.rb +0 -62
  128. data/test/transactions_test.rb +0 -264
  129. data/test/unknown_commands_test.rb +0 -14
  130. data/test/url_param_test.rb +0 -138
@@ -1,14 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
-
5
- class TestUnknownCommands < Test::Unit::TestCase
6
-
7
- include Helper::Client
8
-
9
- def test_should_try_to_work
10
- assert_raise Redis::CommandError do
11
- r.not_yet_implemented_command
12
- end
13
- end
14
- end
@@ -1,138 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
-
5
- class TestUrlParam < Test::Unit::TestCase
6
-
7
- include Helper::Client
8
-
9
- def test_url_defaults_to_______________
10
- redis = Redis.new
11
-
12
- assert_equal "127.0.0.1", redis.client.host
13
- assert_equal 6379, redis.client.port
14
- assert_equal 0, redis.client.db
15
- assert_equal nil, redis.client.password
16
- end
17
-
18
- def test_allows_to_pass_in_a_url
19
- redis = Redis.new :url => "redis://:secr3t@foo.com:999/2"
20
-
21
- assert_equal "foo.com", redis.client.host
22
- assert_equal 999, redis.client.port
23
- assert_equal 2, redis.client.db
24
- assert_equal "secr3t", redis.client.password
25
- end
26
-
27
- def test_allows_to_pass_in_a_url_with_string_key
28
- redis = Redis.new "url" => "redis://:secr3t@foo.com:999/2"
29
-
30
- assert_equal "foo.com", redis.client.host
31
- assert_equal 999, redis.client.port
32
- assert_equal 2, redis.client.db
33
- assert_equal "secr3t", redis.client.password
34
- end
35
-
36
- def test_unescape_password_from_url
37
- redis = Redis.new :url => "redis://:secr3t%3A@foo.com:999/2"
38
-
39
- assert_equal "secr3t:", redis.client.password
40
- end
41
-
42
- def test_unescape_password_from_url_with_string_key
43
- redis = Redis.new "url" => "redis://:secr3t%3A@foo.com:999/2"
44
-
45
- assert_equal "secr3t:", redis.client.password
46
- end
47
-
48
- def test_does_not_unescape_password_when_explicitly_passed
49
- redis = Redis.new :url => "redis://:secr3t%3A@foo.com:999/2", :password => "secr3t%3A"
50
-
51
- assert_equal "secr3t%3A", redis.client.password
52
- end
53
-
54
- def test_does_not_unescape_password_when_explicitly_passed_with_string_key
55
- redis = Redis.new :url => "redis://:secr3t%3A@foo.com:999/2", "password" => "secr3t%3A"
56
-
57
- assert_equal "secr3t%3A", redis.client.password
58
- end
59
-
60
- def test_override_url_if_path_option_is_passed
61
- redis = Redis.new :url => "redis://:secr3t@foo.com/foo:999/2", :path => "/tmp/redis.sock"
62
-
63
- assert_equal "/tmp/redis.sock", redis.client.path
64
- assert_equal nil, redis.client.host
65
- assert_equal nil, redis.client.port
66
- end
67
-
68
- def test_override_url_if_path_option_is_passed_with_string_key
69
- redis = Redis.new :url => "redis://:secr3t@foo.com/foo:999/2", "path" => "/tmp/redis.sock"
70
-
71
- assert_equal "/tmp/redis.sock", redis.client.path
72
- assert_equal nil, redis.client.host
73
- assert_equal nil, redis.client.port
74
- end
75
-
76
- def test_overrides_url_if_another_connection_option_is_passed
77
- redis = Redis.new :url => "redis://:secr3t@foo.com:999/2", :port => 1000
78
-
79
- assert_equal "foo.com", redis.client.host
80
- assert_equal 1000, redis.client.port
81
- assert_equal 2, redis.client.db
82
- assert_equal "secr3t", redis.client.password
83
- end
84
-
85
- def test_overrides_url_if_another_connection_option_is_passed_with_string_key
86
- redis = Redis.new :url => "redis://:secr3t@foo.com:999/2", "port" => 1000
87
-
88
- assert_equal "foo.com", redis.client.host
89
- assert_equal 1000, redis.client.port
90
- assert_equal 2, redis.client.db
91
- assert_equal "secr3t", redis.client.password
92
- end
93
-
94
- def test_does_not_overrides_url_if_a_nil_option_is_passed
95
- redis = Redis.new :url => "redis://:secr3t@foo.com:999/2", :port => nil
96
-
97
- assert_equal "foo.com", redis.client.host
98
- assert_equal 999, redis.client.port
99
- assert_equal 2, redis.client.db
100
- assert_equal "secr3t", redis.client.password
101
- end
102
-
103
- def test_does_not_overrides_url_if_a_nil_option_is_passed_with_string_key
104
- redis = Redis.new :url => "redis://:secr3t@foo.com:999/2", "port" => nil
105
-
106
- assert_equal "foo.com", redis.client.host
107
- assert_equal 999, redis.client.port
108
- assert_equal 2, redis.client.db
109
- assert_equal "secr3t", redis.client.password
110
- end
111
-
112
- def test_does_not_modify_the_passed_options
113
- options = { :url => "redis://:secr3t@foo.com:999/2" }
114
-
115
- Redis.new(options)
116
-
117
- assert({ :url => "redis://:secr3t@foo.com:999/2" } == options)
118
- end
119
-
120
- def test_uses_redis_url_over_default_if_available
121
- ENV["REDIS_URL"] = "redis://:secr3t@foo.com:999/2"
122
-
123
- redis = Redis.new
124
-
125
- assert_equal "foo.com", redis.client.host
126
- assert_equal 999, redis.client.port
127
- assert_equal 2, redis.client.db
128
- assert_equal "secr3t", redis.client.password
129
-
130
- ENV.delete("REDIS_URL")
131
- end
132
-
133
- def test_defaults_to_localhost
134
- redis = Redis.new(:url => "redis:///")
135
-
136
- assert_equal "127.0.0.1", redis.client.host
137
- end
138
- end