redis 4.0.1 → 4.8.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 (148) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +220 -0
  3. data/README.md +152 -28
  4. data/lib/redis/client.rb +171 -107
  5. data/lib/redis/cluster/command.rb +79 -0
  6. data/lib/redis/cluster/command_loader.rb +33 -0
  7. data/lib/redis/cluster/key_slot_converter.rb +72 -0
  8. data/lib/redis/cluster/node.rb +120 -0
  9. data/lib/redis/cluster/node_key.rb +31 -0
  10. data/lib/redis/cluster/node_loader.rb +34 -0
  11. data/lib/redis/cluster/option.rb +100 -0
  12. data/lib/redis/cluster/slot.rb +86 -0
  13. data/lib/redis/cluster/slot_loader.rb +46 -0
  14. data/lib/redis/cluster.rb +315 -0
  15. data/lib/redis/commands/bitmaps.rb +63 -0
  16. data/lib/redis/commands/cluster.rb +45 -0
  17. data/lib/redis/commands/connection.rb +58 -0
  18. data/lib/redis/commands/geo.rb +84 -0
  19. data/lib/redis/commands/hashes.rb +251 -0
  20. data/lib/redis/commands/hyper_log_log.rb +37 -0
  21. data/lib/redis/commands/keys.rb +455 -0
  22. data/lib/redis/commands/lists.rb +290 -0
  23. data/lib/redis/commands/pubsub.rb +72 -0
  24. data/lib/redis/commands/scripting.rb +114 -0
  25. data/lib/redis/commands/server.rb +188 -0
  26. data/lib/redis/commands/sets.rb +223 -0
  27. data/lib/redis/commands/sorted_sets.rb +812 -0
  28. data/lib/redis/commands/streams.rb +382 -0
  29. data/lib/redis/commands/strings.rb +313 -0
  30. data/lib/redis/commands/transactions.rb +139 -0
  31. data/lib/redis/commands.rb +240 -0
  32. data/lib/redis/connection/command_helper.rb +5 -2
  33. data/lib/redis/connection/hiredis.rb +7 -5
  34. data/lib/redis/connection/registry.rb +2 -1
  35. data/lib/redis/connection/ruby.rb +139 -111
  36. data/lib/redis/connection/synchrony.rb +17 -10
  37. data/lib/redis/connection.rb +3 -1
  38. data/lib/redis/distributed.rb +244 -87
  39. data/lib/redis/errors.rb +57 -0
  40. data/lib/redis/hash_ring.rb +15 -14
  41. data/lib/redis/pipeline.rb +181 -10
  42. data/lib/redis/subscribe.rb +11 -12
  43. data/lib/redis/version.rb +3 -1
  44. data/lib/redis.rb +180 -2716
  45. metadata +45 -195
  46. data/.gitignore +0 -16
  47. data/.travis/Gemfile +0 -13
  48. data/.travis.yml +0 -73
  49. data/.yardopts +0 -3
  50. data/Gemfile +0 -3
  51. data/benchmarking/logging.rb +0 -71
  52. data/benchmarking/pipeline.rb +0 -51
  53. data/benchmarking/speed.rb +0 -21
  54. data/benchmarking/suite.rb +0 -24
  55. data/benchmarking/worker.rb +0 -71
  56. data/bors.toml +0 -14
  57. data/examples/basic.rb +0 -15
  58. data/examples/consistency.rb +0 -114
  59. data/examples/dist_redis.rb +0 -43
  60. data/examples/incr-decr.rb +0 -17
  61. data/examples/list.rb +0 -26
  62. data/examples/pubsub.rb +0 -37
  63. data/examples/sentinel/sentinel.conf +0 -9
  64. data/examples/sentinel/start +0 -49
  65. data/examples/sentinel.rb +0 -41
  66. data/examples/sets.rb +0 -36
  67. data/examples/unicorn/config.ru +0 -3
  68. data/examples/unicorn/unicorn.rb +0 -20
  69. data/makefile +0 -42
  70. data/redis.gemspec +0 -42
  71. data/test/bitpos_test.rb +0 -63
  72. data/test/blocking_commands_test.rb +0 -40
  73. data/test/client_test.rb +0 -59
  74. data/test/command_map_test.rb +0 -28
  75. data/test/commands_on_hashes_test.rb +0 -19
  76. data/test/commands_on_hyper_log_log_test.rb +0 -19
  77. data/test/commands_on_lists_test.rb +0 -18
  78. data/test/commands_on_sets_test.rb +0 -75
  79. data/test/commands_on_sorted_sets_test.rb +0 -150
  80. data/test/commands_on_strings_test.rb +0 -99
  81. data/test/commands_on_value_types_test.rb +0 -171
  82. data/test/connection_handling_test.rb +0 -275
  83. data/test/connection_test.rb +0 -57
  84. data/test/db/.gitkeep +0 -0
  85. data/test/distributed_blocking_commands_test.rb +0 -44
  86. data/test/distributed_commands_on_hashes_test.rb +0 -8
  87. data/test/distributed_commands_on_hyper_log_log_test.rb +0 -31
  88. data/test/distributed_commands_on_lists_test.rb +0 -20
  89. data/test/distributed_commands_on_sets_test.rb +0 -106
  90. data/test/distributed_commands_on_sorted_sets_test.rb +0 -16
  91. data/test/distributed_commands_on_strings_test.rb +0 -69
  92. data/test/distributed_commands_on_value_types_test.rb +0 -93
  93. data/test/distributed_commands_requiring_clustering_test.rb +0 -162
  94. data/test/distributed_connection_handling_test.rb +0 -21
  95. data/test/distributed_internals_test.rb +0 -68
  96. data/test/distributed_key_tags_test.rb +0 -50
  97. data/test/distributed_persistence_control_commands_test.rb +0 -24
  98. data/test/distributed_publish_subscribe_test.rb +0 -90
  99. data/test/distributed_remote_server_control_commands_test.rb +0 -64
  100. data/test/distributed_scripting_test.rb +0 -100
  101. data/test/distributed_sorting_test.rb +0 -18
  102. data/test/distributed_test.rb +0 -56
  103. data/test/distributed_transactions_test.rb +0 -30
  104. data/test/encoding_test.rb +0 -14
  105. data/test/error_replies_test.rb +0 -57
  106. data/test/fork_safety_test.rb +0 -60
  107. data/test/helper.rb +0 -201
  108. data/test/helper_test.rb +0 -22
  109. data/test/internals_test.rb +0 -389
  110. data/test/lint/blocking_commands.rb +0 -150
  111. data/test/lint/hashes.rb +0 -162
  112. data/test/lint/hyper_log_log.rb +0 -60
  113. data/test/lint/lists.rb +0 -143
  114. data/test/lint/sets.rb +0 -140
  115. data/test/lint/sorted_sets.rb +0 -316
  116. data/test/lint/strings.rb +0 -246
  117. data/test/lint/value_types.rb +0 -130
  118. data/test/persistence_control_commands_test.rb +0 -24
  119. data/test/pipelining_commands_test.rb +0 -238
  120. data/test/publish_subscribe_test.rb +0 -280
  121. data/test/remote_server_control_commands_test.rb +0 -175
  122. data/test/scanning_test.rb +0 -407
  123. data/test/scripting_test.rb +0 -76
  124. data/test/sentinel_command_test.rb +0 -78
  125. data/test/sentinel_test.rb +0 -253
  126. data/test/sorting_test.rb +0 -57
  127. data/test/ssl_test.rb +0 -69
  128. data/test/support/connection/hiredis.rb +0 -1
  129. data/test/support/connection/ruby.rb +0 -1
  130. data/test/support/connection/synchrony.rb +0 -17
  131. data/test/support/redis_mock.rb +0 -130
  132. data/test/support/ssl/gen_certs.sh +0 -31
  133. data/test/support/ssl/trusted-ca.crt +0 -25
  134. data/test/support/ssl/trusted-ca.key +0 -27
  135. data/test/support/ssl/trusted-cert.crt +0 -81
  136. data/test/support/ssl/trusted-cert.key +0 -28
  137. data/test/support/ssl/untrusted-ca.crt +0 -26
  138. data/test/support/ssl/untrusted-ca.key +0 -27
  139. data/test/support/ssl/untrusted-cert.crt +0 -82
  140. data/test/support/ssl/untrusted-cert.key +0 -28
  141. data/test/support/wire/synchrony.rb +0 -24
  142. data/test/support/wire/thread.rb +0 -5
  143. data/test/synchrony_driver.rb +0 -85
  144. data/test/test.conf.erb +0 -9
  145. data/test/thread_safety_test.rb +0 -60
  146. data/test/transactions_test.rb +0 -262
  147. data/test/unknown_commands_test.rb +0 -12
  148. data/test/url_param_test.rb +0 -136
@@ -1,275 +0,0 @@
1
- require_relative "helper"
2
-
3
- class TestConnectionHandling < Test::Unit::TestCase
4
-
5
- include Helper::Client
6
-
7
- def test_auth
8
- commands = {
9
- :auth => lambda { |password| $auth = password; "+OK" },
10
- :get => lambda { |key| $auth == "secret" ? "$3\r\nbar" : "$-1" },
11
- }
12
-
13
- redis_mock(commands, :password => "secret") do |redis|
14
- assert_equal "bar", redis.get("foo")
15
- end
16
- end
17
-
18
- def test_id
19
- commands = {
20
- :client => lambda { |cmd, name| $name = [cmd, name]; "+OK" },
21
- :ping => lambda { "+PONG" },
22
- }
23
-
24
- redis_mock(commands, :id => "client-name") do |redis|
25
- assert_equal "PONG", redis.ping
26
- end
27
-
28
- assert_equal ["setname","client-name"], $name
29
- end
30
-
31
- def test_ping
32
- assert_equal "PONG", r.ping
33
- end
34
-
35
- def test_select
36
- r.set "foo", "bar"
37
-
38
- r.select 14
39
- assert_equal nil, r.get("foo")
40
-
41
- r._client.disconnect
42
-
43
- assert_equal nil, r.get("foo")
44
- end
45
-
46
- def test_quit
47
- r.quit
48
-
49
- assert !r._client.connected?
50
- end
51
-
52
- def test_close
53
- quit = 0
54
-
55
- commands = {
56
- :quit => lambda do
57
- quit += 1
58
- "+OK"
59
- end
60
- }
61
-
62
- redis_mock(commands) do |redis|
63
- assert_equal 0, quit
64
-
65
- redis.quit
66
-
67
- assert_equal 1, quit
68
-
69
- redis.ping
70
-
71
- redis.close
72
-
73
- assert_equal 1, quit
74
-
75
- assert !redis.connected?
76
- end
77
- end
78
-
79
- def test_disconnect
80
- quit = 0
81
-
82
- commands = {
83
- :quit => lambda do
84
- quit += 1
85
- "+OK"
86
- end
87
- }
88
-
89
- redis_mock(commands) do |redis|
90
- assert_equal 0, quit
91
-
92
- redis.quit
93
-
94
- assert_equal 1, quit
95
-
96
- redis.ping
97
-
98
- redis.disconnect!
99
-
100
- assert_equal 1, quit
101
-
102
- assert !redis.connected?
103
- end
104
- end
105
-
106
- def test_shutdown
107
- commands = {
108
- :shutdown => lambda { :exit }
109
- }
110
-
111
- redis_mock(commands) do |redis|
112
- # SHUTDOWN does not reply: test that it does not raise here.
113
- assert_equal nil, redis.shutdown
114
- end
115
- end
116
-
117
- def test_shutdown_with_error
118
- connections = 0
119
- commands = {
120
- :select => lambda { |*_| connections += 1; "+OK\r\n" },
121
- :connections => lambda { ":#{connections}\r\n" },
122
- :shutdown => lambda { "-ERR could not shutdown\r\n" }
123
- }
124
-
125
- redis_mock(commands) do |redis|
126
- connections = redis.connections
127
-
128
- # SHUTDOWN replies with an error: test that it gets raised
129
- assert_raise Redis::CommandError do
130
- redis.shutdown
131
- end
132
-
133
- # The connection should remain in tact
134
- assert_equal connections, redis.connections
135
- end
136
- end
137
-
138
- def test_shutdown_from_pipeline
139
- commands = {
140
- :shutdown => lambda { :exit }
141
- }
142
-
143
- redis_mock(commands) do |redis|
144
- result = redis.pipelined do
145
- redis.shutdown
146
- end
147
-
148
- assert_equal nil, result
149
- assert !redis._client.connected?
150
- end
151
- end
152
-
153
- def test_shutdown_with_error_from_pipeline
154
- connections = 0
155
- commands = {
156
- :select => lambda { |*_| connections += 1; "+OK\r\n" },
157
- :connections => lambda { ":#{connections}\r\n" },
158
- :shutdown => lambda { "-ERR could not shutdown\r\n" }
159
- }
160
-
161
- redis_mock(commands) do |redis|
162
- connections = redis.connections
163
-
164
- # SHUTDOWN replies with an error: test that it gets raised
165
- assert_raise Redis::CommandError do
166
- redis.pipelined do
167
- redis.shutdown
168
- end
169
- end
170
-
171
- # The connection should remain in tact
172
- assert_equal connections, redis.connections
173
- end
174
- end
175
-
176
- def test_shutdown_from_multi_exec
177
- commands = {
178
- :multi => lambda { "+OK\r\n" },
179
- :shutdown => lambda { "+QUEUED\r\n" },
180
- :exec => lambda { :exit }
181
- }
182
-
183
- redis_mock(commands) do |redis|
184
- result = redis.multi do
185
- redis.shutdown
186
- end
187
-
188
- assert_equal nil, result
189
- assert !redis._client.connected?
190
- end
191
- end
192
-
193
- def test_shutdown_with_error_from_multi_exec
194
- connections = 0
195
- commands = {
196
- :select => lambda { |*_| connections += 1; "+OK\r\n" },
197
- :connections => lambda { ":#{connections}\r\n" },
198
- :multi => lambda { "+OK\r\n" },
199
- :shutdown => lambda { "+QUEUED\r\n" },
200
- :exec => lambda { "*1\r\n-ERR could not shutdown\r\n" }
201
- }
202
-
203
- redis_mock(commands) do |redis|
204
- connections = redis.connections
205
-
206
- # SHUTDOWN replies with an error: test that it gets returned
207
- # We should test for Redis::CommandError here, but hiredis doesn't yet do
208
- # custom error classes.
209
- err = nil
210
-
211
- begin
212
- redis.multi { redis.shutdown }
213
- rescue => err
214
- end
215
-
216
- assert err.kind_of?(StandardError)
217
-
218
- # The connection should remain intact
219
- assert_equal connections, redis.connections
220
- end
221
- end
222
-
223
- def test_slaveof
224
- redis_mock(:slaveof => lambda { |host, port| "+SLAVEOF #{host} #{port}" }) do |redis|
225
- assert_equal "SLAVEOF somehost 6381", redis.slaveof("somehost", 6381)
226
- end
227
- end
228
-
229
- def test_bgrewriteaof
230
- redis_mock(:bgrewriteaof => lambda { "+BGREWRITEAOF" }) do |redis|
231
- assert_equal "BGREWRITEAOF", redis.bgrewriteaof
232
- end
233
- end
234
-
235
- def test_config_get
236
- assert r.config(:get, "*")["timeout"] != nil
237
-
238
- config = r.config(:get, "timeout")
239
- assert_equal ["timeout"], config.keys
240
- assert config.values.compact.size > 0
241
- end
242
-
243
- def test_config_set
244
- begin
245
- assert_equal "OK", r.config(:set, "timeout", 200)
246
- assert_equal "200", r.config(:get, "*")["timeout"]
247
-
248
- assert_equal "OK", r.config(:set, "timeout", 100)
249
- assert_equal "100", r.config(:get, "*")["timeout"]
250
- ensure
251
- r.config :set, "timeout", 300
252
- end
253
- end
254
-
255
- driver(:ruby, :hiredis) do
256
- def test_consistency_on_multithreaded_env
257
- t = nil
258
-
259
- commands = {
260
- :set => lambda { |key, value| t.kill; "+OK\r\n" },
261
- :incr => lambda { |key| ":1\r\n" },
262
- }
263
-
264
- redis_mock(commands) do |redis|
265
- t = Thread.new do
266
- redis.set("foo", "bar")
267
- end
268
-
269
- t.join
270
-
271
- assert_equal 1, redis.incr("baz")
272
- end
273
- end
274
- end
275
- end
@@ -1,57 +0,0 @@
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/db/.gitkeep DELETED
File without changes
@@ -1,44 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/blocking_commands"
3
-
4
- class TestDistributedBlockingCommands < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::BlockingCommands
8
-
9
- def test_blpop_raises
10
- assert_raises(Redis::Distributed::CannotDistribute) do
11
- r.blpop(["foo", "bar"])
12
- end
13
- end
14
-
15
- def test_blpop_raises_with_old_prototype
16
- assert_raises(Redis::Distributed::CannotDistribute) do
17
- r.blpop("foo", "bar", 0)
18
- end
19
- end
20
-
21
- def test_brpop_raises
22
- assert_raises(Redis::Distributed::CannotDistribute) do
23
- r.brpop(["foo", "bar"])
24
- end
25
- end
26
-
27
- def test_brpop_raises_with_old_prototype
28
- assert_raises(Redis::Distributed::CannotDistribute) do
29
- r.brpop("foo", "bar", 0)
30
- end
31
- end
32
-
33
- def test_brpoplpush_raises
34
- assert_raises(Redis::Distributed::CannotDistribute) do
35
- r.brpoplpush("foo", "bar")
36
- end
37
- end
38
-
39
- def test_brpoplpush_raises_with_old_prototype
40
- assert_raises(Redis::Distributed::CannotDistribute) do
41
- r.brpoplpush("foo", "bar", 0)
42
- end
43
- end
44
- end
@@ -1,8 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/hashes"
3
-
4
- class TestDistributedCommandsOnHashes < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::Hashes
8
- end
@@ -1,31 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/hyper_log_log"
3
-
4
- class TestDistributedCommandsOnHyperLogLog < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::HyperLogLog
8
-
9
- def test_pfmerge
10
- target_version "2.8.9" do
11
- assert_raise Redis::Distributed::CannotDistribute do
12
- r.pfadd "foo", "s1"
13
- r.pfadd "bar", "s2"
14
-
15
- assert r.pfmerge("res", "foo", "bar")
16
- end
17
- end
18
- end
19
-
20
- def test_pfcount_multiple_keys_diff_nodes
21
- target_version "2.8.9" do
22
- assert_raise Redis::Distributed::CannotDistribute do
23
- r.pfadd "foo", "s1"
24
- r.pfadd "bar", "s2"
25
-
26
- assert r.pfcount("res", "foo", "bar")
27
- end
28
- end
29
- end
30
-
31
- end
@@ -1,20 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/lists"
3
-
4
- class TestDistributedCommandsOnLists < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::Lists
8
-
9
- def test_rpoplpush
10
- assert_raise Redis::Distributed::CannotDistribute do
11
- r.rpoplpush("foo", "bar")
12
- end
13
- end
14
-
15
- def test_brpoplpush
16
- assert_raise Redis::Distributed::CannotDistribute do
17
- r.brpoplpush("foo", "bar", :timeout => 1)
18
- end
19
- end
20
- end
@@ -1,106 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/sets"
3
-
4
- class TestDistributedCommandsOnSets < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::Sets
8
-
9
- def test_smove
10
- assert_raise Redis::Distributed::CannotDistribute do
11
- r.sadd "foo", "s1"
12
- r.sadd "bar", "s2"
13
-
14
- r.smove("foo", "bar", "s1")
15
- end
16
- end
17
-
18
- def test_sinter
19
- assert_raise Redis::Distributed::CannotDistribute do
20
- r.sadd "foo", "s1"
21
- r.sadd "foo", "s2"
22
- r.sadd "bar", "s2"
23
-
24
- r.sinter("foo", "bar")
25
- end
26
- end
27
-
28
- def test_sinterstore
29
- assert_raise Redis::Distributed::CannotDistribute do
30
- r.sadd "foo", "s1"
31
- r.sadd "foo", "s2"
32
- r.sadd "bar", "s2"
33
-
34
- r.sinterstore("baz", "foo", "bar")
35
- end
36
- end
37
-
38
- def test_sunion
39
- assert_raise Redis::Distributed::CannotDistribute do
40
- r.sadd "foo", "s1"
41
- r.sadd "foo", "s2"
42
- r.sadd "bar", "s2"
43
- r.sadd "bar", "s3"
44
-
45
- r.sunion("foo", "bar")
46
- end
47
- end
48
-
49
- def test_sunionstore
50
- assert_raise Redis::Distributed::CannotDistribute do
51
- r.sadd "foo", "s1"
52
- r.sadd "foo", "s2"
53
- r.sadd "bar", "s2"
54
- r.sadd "bar", "s3"
55
-
56
- r.sunionstore("baz", "foo", "bar")
57
- end
58
- end
59
-
60
- def test_sdiff
61
- assert_raise Redis::Distributed::CannotDistribute do
62
- r.sadd "foo", "s1"
63
- r.sadd "foo", "s2"
64
- r.sadd "bar", "s2"
65
- r.sadd "bar", "s3"
66
-
67
- r.sdiff("foo", "bar")
68
- end
69
- end
70
-
71
- def test_sdiffstore
72
- assert_raise Redis::Distributed::CannotDistribute do
73
- r.sadd "foo", "s1"
74
- r.sadd "foo", "s2"
75
- r.sadd "bar", "s2"
76
- r.sadd "bar", "s3"
77
-
78
- r.sdiffstore("baz", "foo", "bar")
79
- end
80
- end
81
-
82
- def test_sscan
83
- assert_nothing_raised do
84
- r.sadd "foo", "s1"
85
- r.sadd "foo", "s2"
86
- r.sadd "bar", "s2"
87
- r.sadd "bar", "s3"
88
-
89
- cursor, vals = r.sscan "foo", 0
90
- assert_equal '0', cursor
91
- assert_equal %w(s1 s2), vals.sort
92
- end
93
- end
94
-
95
- def test_sscan_each
96
- assert_nothing_raised do
97
- r.sadd "foo", "s1"
98
- r.sadd "foo", "s2"
99
- r.sadd "bar", "s2"
100
- r.sadd "bar", "s3"
101
-
102
- vals = r.sscan_each("foo").to_a
103
- assert_equal %w(s1 s2), vals.sort
104
- end
105
- end
106
- end
@@ -1,16 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/sorted_sets"
3
-
4
- class TestDistributedCommandsOnSortedSets < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::SortedSets
8
-
9
- def test_zcount
10
- r.zadd "foo", 1, "s1"
11
- r.zadd "foo", 2, "s2"
12
- r.zadd "foo", 3, "s3"
13
-
14
- assert_equal 2, r.zcount("foo", 2, 3)
15
- end
16
- end
@@ -1,69 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/strings"
3
-
4
- class TestDistributedCommandsOnStrings < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::Strings
8
-
9
- def test_mget
10
- r.set("foo", "s1")
11
- r.set("bar", "s2")
12
-
13
- assert_equal ["s1", "s2"] , r.mget("foo", "bar")
14
- assert_equal ["s1", "s2", nil], r.mget("foo", "bar", "baz")
15
- end
16
-
17
- def test_mget_mapped
18
- r.set("foo", "s1")
19
- r.set("bar", "s2")
20
-
21
- response = r.mapped_mget("foo", "bar")
22
-
23
- assert_equal "s1", response["foo"]
24
- assert_equal "s2", response["bar"]
25
-
26
- response = r.mapped_mget("foo", "bar", "baz")
27
-
28
- assert_equal "s1", response["foo"]
29
- assert_equal "s2", response["bar"]
30
- assert_equal nil , response["baz"]
31
- end
32
-
33
- def test_mset
34
- assert_raise Redis::Distributed::CannotDistribute do
35
- r.mset(:foo, "s1", :bar, "s2")
36
- end
37
- end
38
-
39
- def test_mset_mapped
40
- assert_raise Redis::Distributed::CannotDistribute do
41
- r.mapped_mset(:foo => "s1", :bar => "s2")
42
- end
43
- end
44
-
45
- def test_msetnx
46
- assert_raise Redis::Distributed::CannotDistribute do
47
- r.set("foo", "s1")
48
- r.msetnx(:foo, "s2", :bar, "s3")
49
- end
50
- end
51
-
52
- def test_msetnx_mapped
53
- assert_raise Redis::Distributed::CannotDistribute do
54
- r.set("foo", "s1")
55
- r.mapped_msetnx(:foo => "s2", :bar => "s3")
56
- end
57
- end
58
-
59
- def test_bitop
60
- target_version "2.5.10" do
61
- assert_raise Redis::Distributed::CannotDistribute do
62
- r.set("foo", "a")
63
- r.set("bar", "b")
64
-
65
- r.bitop(:and, "foo&bar", "foo", "bar")
66
- end
67
- end
68
- end
69
- end