redis 3.3.5 → 4.8.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 +5 -5
- data/CHANGELOG.md +232 -2
- data/README.md +169 -89
- data/lib/redis/client.rb +177 -100
- data/lib/redis/cluster/command.rb +79 -0
- data/lib/redis/cluster/command_loader.rb +33 -0
- data/lib/redis/cluster/key_slot_converter.rb +72 -0
- data/lib/redis/cluster/node.rb +120 -0
- data/lib/redis/cluster/node_key.rb +31 -0
- data/lib/redis/cluster/node_loader.rb +34 -0
- data/lib/redis/cluster/option.rb +100 -0
- data/lib/redis/cluster/slot.rb +86 -0
- data/lib/redis/cluster/slot_loader.rb +46 -0
- data/lib/redis/cluster.rb +315 -0
- data/lib/redis/commands/bitmaps.rb +63 -0
- data/lib/redis/commands/cluster.rb +45 -0
- data/lib/redis/commands/connection.rb +58 -0
- data/lib/redis/commands/geo.rb +84 -0
- data/lib/redis/commands/hashes.rb +251 -0
- data/lib/redis/commands/hyper_log_log.rb +37 -0
- data/lib/redis/commands/keys.rb +455 -0
- data/lib/redis/commands/lists.rb +290 -0
- data/lib/redis/commands/pubsub.rb +72 -0
- data/lib/redis/commands/scripting.rb +114 -0
- data/lib/redis/commands/server.rb +188 -0
- data/lib/redis/commands/sets.rb +223 -0
- data/lib/redis/commands/sorted_sets.rb +812 -0
- data/lib/redis/commands/streams.rb +382 -0
- data/lib/redis/commands/strings.rb +313 -0
- data/lib/redis/commands/transactions.rb +139 -0
- data/lib/redis/commands.rb +240 -0
- data/lib/redis/connection/command_helper.rb +7 -10
- data/lib/redis/connection/hiredis.rb +5 -3
- data/lib/redis/connection/registry.rb +2 -1
- data/lib/redis/connection/ruby.rb +136 -128
- data/lib/redis/connection/synchrony.rb +24 -9
- data/lib/redis/connection.rb +3 -1
- data/lib/redis/distributed.rb +255 -85
- data/lib/redis/errors.rb +57 -0
- data/lib/redis/hash_ring.rb +30 -73
- data/lib/redis/pipeline.rb +178 -13
- data/lib/redis/subscribe.rb +11 -12
- data/lib/redis/version.rb +3 -1
- data/lib/redis.rb +174 -2661
- metadata +66 -202
- data/.gitignore +0 -16
- data/.travis/Gemfile +0 -11
- data/.travis.yml +0 -89
- data/.yardopts +0 -3
- data/Gemfile +0 -4
- data/Rakefile +0 -87
- data/benchmarking/logging.rb +0 -71
- data/benchmarking/pipeline.rb +0 -51
- data/benchmarking/speed.rb +0 -21
- data/benchmarking/suite.rb +0 -24
- data/benchmarking/worker.rb +0 -71
- data/examples/basic.rb +0 -15
- data/examples/consistency.rb +0 -114
- data/examples/dist_redis.rb +0 -43
- data/examples/incr-decr.rb +0 -17
- data/examples/list.rb +0 -26
- data/examples/pubsub.rb +0 -37
- data/examples/sentinel/sentinel.conf +0 -9
- data/examples/sentinel/start +0 -49
- data/examples/sentinel.rb +0 -41
- data/examples/sets.rb +0 -36
- data/examples/unicorn/config.ru +0 -3
- data/examples/unicorn/unicorn.rb +0 -20
- data/redis.gemspec +0 -44
- data/test/bitpos_test.rb +0 -69
- data/test/blocking_commands_test.rb +0 -42
- data/test/client_test.rb +0 -59
- data/test/command_map_test.rb +0 -30
- data/test/commands_on_hashes_test.rb +0 -21
- data/test/commands_on_hyper_log_log_test.rb +0 -21
- data/test/commands_on_lists_test.rb +0 -20
- data/test/commands_on_sets_test.rb +0 -77
- data/test/commands_on_sorted_sets_test.rb +0 -137
- data/test/commands_on_strings_test.rb +0 -101
- data/test/commands_on_value_types_test.rb +0 -133
- data/test/connection_handling_test.rb +0 -277
- data/test/connection_test.rb +0 -57
- data/test/db/.gitkeep +0 -0
- data/test/distributed_blocking_commands_test.rb +0 -46
- data/test/distributed_commands_on_hashes_test.rb +0 -10
- data/test/distributed_commands_on_hyper_log_log_test.rb +0 -33
- data/test/distributed_commands_on_lists_test.rb +0 -22
- data/test/distributed_commands_on_sets_test.rb +0 -83
- data/test/distributed_commands_on_sorted_sets_test.rb +0 -18
- data/test/distributed_commands_on_strings_test.rb +0 -59
- data/test/distributed_commands_on_value_types_test.rb +0 -95
- data/test/distributed_commands_requiring_clustering_test.rb +0 -164
- data/test/distributed_connection_handling_test.rb +0 -23
- data/test/distributed_internals_test.rb +0 -79
- data/test/distributed_key_tags_test.rb +0 -52
- data/test/distributed_persistence_control_commands_test.rb +0 -26
- data/test/distributed_publish_subscribe_test.rb +0 -92
- data/test/distributed_remote_server_control_commands_test.rb +0 -66
- data/test/distributed_scripting_test.rb +0 -102
- data/test/distributed_sorting_test.rb +0 -20
- data/test/distributed_test.rb +0 -58
- data/test/distributed_transactions_test.rb +0 -32
- data/test/encoding_test.rb +0 -18
- data/test/error_replies_test.rb +0 -59
- data/test/fork_safety_test.rb +0 -65
- data/test/helper.rb +0 -232
- data/test/helper_test.rb +0 -24
- data/test/internals_test.rb +0 -417
- data/test/lint/blocking_commands.rb +0 -150
- data/test/lint/hashes.rb +0 -162
- data/test/lint/hyper_log_log.rb +0 -60
- data/test/lint/lists.rb +0 -143
- data/test/lint/sets.rb +0 -140
- data/test/lint/sorted_sets.rb +0 -316
- data/test/lint/strings.rb +0 -260
- data/test/lint/value_types.rb +0 -122
- data/test/persistence_control_commands_test.rb +0 -26
- data/test/pipelining_commands_test.rb +0 -242
- data/test/publish_subscribe_test.rb +0 -282
- data/test/remote_server_control_commands_test.rb +0 -118
- data/test/scanning_test.rb +0 -413
- data/test/scripting_test.rb +0 -78
- data/test/sentinel_command_test.rb +0 -80
- data/test/sentinel_test.rb +0 -255
- data/test/sorting_test.rb +0 -59
- data/test/ssl_test.rb +0 -73
- data/test/support/connection/hiredis.rb +0 -1
- data/test/support/connection/ruby.rb +0 -1
- data/test/support/connection/synchrony.rb +0 -17
- data/test/support/redis_mock.rb +0 -130
- data/test/support/ssl/gen_certs.sh +0 -31
- data/test/support/ssl/trusted-ca.crt +0 -25
- data/test/support/ssl/trusted-ca.key +0 -27
- data/test/support/ssl/trusted-cert.crt +0 -81
- data/test/support/ssl/trusted-cert.key +0 -28
- data/test/support/ssl/untrusted-ca.crt +0 -26
- data/test/support/ssl/untrusted-ca.key +0 -27
- data/test/support/ssl/untrusted-cert.crt +0 -82
- data/test/support/ssl/untrusted-cert.key +0 -28
- data/test/support/wire/synchrony.rb +0 -24
- data/test/support/wire/thread.rb +0 -5
- data/test/synchrony_driver.rb +0 -88
- data/test/test.conf.erb +0 -9
- data/test/thread_safety_test.rb +0 -62
- data/test/transactions_test.rb +0 -264
- data/test/unknown_commands_test.rb +0 -14
- data/test/url_param_test.rb +0 -138
data/test/transactions_test.rb
DELETED
@@ -1,264 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
4
|
-
|
5
|
-
class TestTransactions < Test::Unit::TestCase
|
6
|
-
|
7
|
-
include Helper::Client
|
8
|
-
|
9
|
-
def test_multi_discard
|
10
|
-
r.multi
|
11
|
-
|
12
|
-
assert_equal "QUEUED", r.set("foo", "1")
|
13
|
-
assert_equal "QUEUED", r.get("foo")
|
14
|
-
|
15
|
-
r.discard
|
16
|
-
|
17
|
-
assert_equal nil, r.get("foo")
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_multi_exec_with_a_block
|
21
|
-
r.multi do |multi|
|
22
|
-
multi.set "foo", "s1"
|
23
|
-
end
|
24
|
-
|
25
|
-
assert_equal "s1", r.get("foo")
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_multi_exec_with_a_block_doesn_t_return_replies_for_multi_and_exec
|
29
|
-
r1, r2, nothing_else = r.multi do |multi|
|
30
|
-
multi.set "foo", "s1"
|
31
|
-
multi.get "foo"
|
32
|
-
end
|
33
|
-
|
34
|
-
assert_equal "OK", r1
|
35
|
-
assert_equal "s1", r2
|
36
|
-
assert_equal nil, nothing_else
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_assignment_inside_multi_exec_block
|
40
|
-
r.multi do |m|
|
41
|
-
@first = m.sadd("foo", 1)
|
42
|
-
@second = m.sadd("foo", 1)
|
43
|
-
end
|
44
|
-
|
45
|
-
assert_equal true, @first.value
|
46
|
-
assert_equal false, @second.value
|
47
|
-
end
|
48
|
-
|
49
|
-
# Although we could support accessing the values in these futures,
|
50
|
-
# it doesn't make a lot of sense.
|
51
|
-
def test_assignment_inside_multi_exec_block_with_delayed_command_errors
|
52
|
-
assert_raise(Redis::CommandError) do
|
53
|
-
r.multi do |m|
|
54
|
-
@first = m.set("foo", "s1")
|
55
|
-
@second = m.incr("foo") # not an integer
|
56
|
-
@third = m.lpush("foo", "value") # wrong kind of value
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
assert_equal "OK", @first.value
|
61
|
-
assert_raise(Redis::CommandError) { @second.value }
|
62
|
-
assert_raise(Redis::FutureNotReady) { @third.value }
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_assignment_inside_multi_exec_block_with_immediate_command_errors
|
66
|
-
assert_raise(Redis::CommandError) do
|
67
|
-
r.multi do |m|
|
68
|
-
m.doesnt_exist
|
69
|
-
@first = m.sadd("foo", 1)
|
70
|
-
@second = m.sadd("foo", 1)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
assert_raise(Redis::FutureNotReady) { @first.value }
|
75
|
-
assert_raise(Redis::FutureNotReady) { @second.value }
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_raise_immediate_errors_in_multi_exec
|
79
|
-
assert_raise(RuntimeError) do
|
80
|
-
r.multi do |multi|
|
81
|
-
multi.set "bar", "s2"
|
82
|
-
raise "Some error"
|
83
|
-
multi.set "baz", "s3"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
assert_equal nil, r.get("bar")
|
88
|
-
assert_equal nil, r.get("baz")
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_transformed_replies_as_return_values_for_multi_exec_block
|
92
|
-
info, _ = r.multi do |m|
|
93
|
-
r.info
|
94
|
-
end
|
95
|
-
|
96
|
-
assert info.kind_of?(Hash)
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_transformed_replies_inside_multi_exec_block
|
100
|
-
r.multi do |m|
|
101
|
-
@info = r.info
|
102
|
-
end
|
103
|
-
|
104
|
-
assert @info.value.kind_of?(Hash)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_raise_command_errors_in_multi_exec
|
108
|
-
assert_raise(Redis::CommandError) do
|
109
|
-
r.multi do |m|
|
110
|
-
m.set("foo", "s1")
|
111
|
-
m.incr("foo") # not an integer
|
112
|
-
m.lpush("foo", "value") # wrong kind of value
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
assert_equal "s1", r.get("foo")
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_raise_command_errors_when_accessing_futures_after_multi_exec
|
120
|
-
begin
|
121
|
-
r.multi do |m|
|
122
|
-
m.set("foo", "s1")
|
123
|
-
@counter = m.incr("foo") # not an integer
|
124
|
-
end
|
125
|
-
rescue Exception
|
126
|
-
# Not gonna deal with it
|
127
|
-
end
|
128
|
-
|
129
|
-
# We should test for Redis::Error here, but hiredis doesn't yet do
|
130
|
-
# custom error classes.
|
131
|
-
err = nil
|
132
|
-
begin
|
133
|
-
@counter.value
|
134
|
-
rescue => err
|
135
|
-
end
|
136
|
-
|
137
|
-
assert err.kind_of?(RuntimeError)
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_multi_with_a_block_yielding_the_client
|
141
|
-
r.multi do |multi|
|
142
|
-
multi.set "foo", "s1"
|
143
|
-
end
|
144
|
-
|
145
|
-
assert_equal "s1", r.get("foo")
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_raise_command_error_when_exec_fails
|
149
|
-
redis_mock(:exec => lambda { |*_| "-ERROR" }) do |redis|
|
150
|
-
assert_raise(Redis::CommandError) do
|
151
|
-
redis.multi do |m|
|
152
|
-
m.set "foo", "s1"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_watch
|
159
|
-
res = r.watch "foo"
|
160
|
-
|
161
|
-
assert_equal "OK", res
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_watch_with_an_unmodified_key
|
165
|
-
r.watch "foo"
|
166
|
-
r.multi do |multi|
|
167
|
-
multi.set "foo", "s1"
|
168
|
-
end
|
169
|
-
|
170
|
-
assert_equal "s1", r.get("foo")
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_watch_with_an_unmodified_key_passed_as_array
|
174
|
-
r.watch ["foo", "bar"]
|
175
|
-
r.multi do |multi|
|
176
|
-
multi.set "foo", "s1"
|
177
|
-
end
|
178
|
-
|
179
|
-
assert_equal "s1", r.get("foo")
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_watch_with_a_modified_key
|
183
|
-
r.watch "foo"
|
184
|
-
r.set "foo", "s1"
|
185
|
-
res = r.multi do |multi|
|
186
|
-
multi.set "foo", "s2"
|
187
|
-
end
|
188
|
-
|
189
|
-
assert_equal nil, res
|
190
|
-
assert_equal "s1", r.get("foo")
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_watch_with_a_modified_key_passed_as_array
|
194
|
-
r.watch ["foo", "bar"]
|
195
|
-
r.set "foo", "s1"
|
196
|
-
res = r.multi do |multi|
|
197
|
-
multi.set "foo", "s2"
|
198
|
-
end
|
199
|
-
|
200
|
-
assert_equal nil, res
|
201
|
-
assert_equal "s1", r.get("foo")
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_watch_with_a_block_and_an_unmodified_key
|
205
|
-
result = r.watch "foo" do |rd|
|
206
|
-
|
207
|
-
assert_same r, rd
|
208
|
-
|
209
|
-
rd.multi do |multi|
|
210
|
-
multi.set "foo", "s1"
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
assert_equal ["OK"], result
|
215
|
-
assert_equal "s1", r.get("foo")
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_watch_with_a_block_and_a_modified_key
|
219
|
-
result = r.watch "foo" do |rd|
|
220
|
-
|
221
|
-
assert_same r, rd
|
222
|
-
|
223
|
-
rd.set "foo", "s1"
|
224
|
-
rd.multi do |multi|
|
225
|
-
multi.set "foo", "s2"
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
assert_equal nil, result
|
230
|
-
assert_equal "s1", r.get("foo")
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_watch_with_a_block_that_raises_an_exception
|
234
|
-
r.set("foo", "s1")
|
235
|
-
|
236
|
-
begin
|
237
|
-
r.watch "foo" do
|
238
|
-
raise "test"
|
239
|
-
end
|
240
|
-
rescue RuntimeError
|
241
|
-
end
|
242
|
-
|
243
|
-
r.set("foo", "s2")
|
244
|
-
|
245
|
-
# If the watch was still set from within the block above, this multi/exec
|
246
|
-
# would fail. This proves that raising an exception above unwatches.
|
247
|
-
r.multi do |multi|
|
248
|
-
multi.set "foo", "s3"
|
249
|
-
end
|
250
|
-
|
251
|
-
assert_equal "s3", r.get("foo")
|
252
|
-
end
|
253
|
-
|
254
|
-
def test_unwatch_with_a_modified_key
|
255
|
-
r.watch "foo"
|
256
|
-
r.set "foo", "s1"
|
257
|
-
r.unwatch
|
258
|
-
r.multi do |multi|
|
259
|
-
multi.set "foo", "s2"
|
260
|
-
end
|
261
|
-
|
262
|
-
assert_equal "s2", r.get("foo")
|
263
|
-
end
|
264
|
-
end
|
@@ -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
|
data/test/url_param_test.rb
DELETED
@@ -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
|