redis 4.0.3 → 4.5.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 (157) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +110 -0
  3. data/README.md +126 -17
  4. data/lib/redis/client.rb +130 -82
  5. data/lib/redis/cluster/command_loader.rb +8 -7
  6. data/lib/redis/cluster/node.rb +5 -1
  7. data/lib/redis/cluster/node_key.rb +3 -7
  8. data/lib/redis/cluster/node_loader.rb +2 -0
  9. data/lib/redis/cluster/option.rb +31 -14
  10. data/lib/redis/cluster/slot.rb +30 -13
  11. data/lib/redis/cluster/slot_loader.rb +6 -4
  12. data/lib/redis/cluster.rb +23 -17
  13. data/lib/redis/connection/command_helper.rb +5 -2
  14. data/lib/redis/connection/hiredis.rb +4 -3
  15. data/lib/redis/connection/registry.rb +2 -1
  16. data/lib/redis/connection/ruby.rb +139 -106
  17. data/lib/redis/connection/synchrony.rb +9 -4
  18. data/lib/redis/connection.rb +2 -0
  19. data/lib/redis/distributed.rb +171 -70
  20. data/lib/redis/errors.rb +2 -0
  21. data/lib/redis/hash_ring.rb +15 -14
  22. data/lib/redis/pipeline.rb +46 -8
  23. data/lib/redis/subscribe.rb +11 -12
  24. data/lib/redis/version.rb +3 -1
  25. data/lib/redis.rb +1239 -426
  26. metadata +16 -262
  27. data/.gitignore +0 -19
  28. data/.travis/Gemfile +0 -18
  29. data/.travis.yml +0 -61
  30. data/.yardopts +0 -3
  31. data/Gemfile +0 -8
  32. data/benchmarking/logging.rb +0 -71
  33. data/benchmarking/pipeline.rb +0 -51
  34. data/benchmarking/speed.rb +0 -21
  35. data/benchmarking/suite.rb +0 -24
  36. data/benchmarking/worker.rb +0 -71
  37. data/bin/build +0 -71
  38. data/bors.toml +0 -14
  39. data/examples/basic.rb +0 -15
  40. data/examples/consistency.rb +0 -114
  41. data/examples/dist_redis.rb +0 -43
  42. data/examples/incr-decr.rb +0 -17
  43. data/examples/list.rb +0 -26
  44. data/examples/pubsub.rb +0 -37
  45. data/examples/sentinel/sentinel.conf +0 -9
  46. data/examples/sentinel/start +0 -49
  47. data/examples/sentinel.rb +0 -41
  48. data/examples/sets.rb +0 -36
  49. data/examples/unicorn/config.ru +0 -3
  50. data/examples/unicorn/unicorn.rb +0 -20
  51. data/makefile +0 -74
  52. data/redis.gemspec +0 -43
  53. data/test/bitpos_test.rb +0 -63
  54. data/test/blocking_commands_test.rb +0 -40
  55. data/test/client_test.rb +0 -76
  56. data/test/cluster_abnormal_state_test.rb +0 -38
  57. data/test/cluster_blocking_commands_test.rb +0 -15
  58. data/test/cluster_client_internals_test.rb +0 -77
  59. data/test/cluster_client_key_hash_tags_test.rb +0 -88
  60. data/test/cluster_client_options_test.rb +0 -147
  61. data/test/cluster_client_pipelining_test.rb +0 -59
  62. data/test/cluster_client_replicas_test.rb +0 -36
  63. data/test/cluster_client_slots_test.rb +0 -94
  64. data/test/cluster_client_transactions_test.rb +0 -71
  65. data/test/cluster_commands_on_cluster_test.rb +0 -165
  66. data/test/cluster_commands_on_connection_test.rb +0 -40
  67. data/test/cluster_commands_on_geo_test.rb +0 -74
  68. data/test/cluster_commands_on_hashes_test.rb +0 -11
  69. data/test/cluster_commands_on_hyper_log_log_test.rb +0 -17
  70. data/test/cluster_commands_on_keys_test.rb +0 -134
  71. data/test/cluster_commands_on_lists_test.rb +0 -15
  72. data/test/cluster_commands_on_pub_sub_test.rb +0 -101
  73. data/test/cluster_commands_on_scripting_test.rb +0 -56
  74. data/test/cluster_commands_on_server_test.rb +0 -221
  75. data/test/cluster_commands_on_sets_test.rb +0 -39
  76. data/test/cluster_commands_on_sorted_sets_test.rb +0 -35
  77. data/test/cluster_commands_on_streams_test.rb +0 -196
  78. data/test/cluster_commands_on_strings_test.rb +0 -15
  79. data/test/cluster_commands_on_transactions_test.rb +0 -41
  80. data/test/cluster_commands_on_value_types_test.rb +0 -14
  81. data/test/command_map_test.rb +0 -28
  82. data/test/commands_on_geo_test.rb +0 -116
  83. data/test/commands_on_hashes_test.rb +0 -7
  84. data/test/commands_on_hyper_log_log_test.rb +0 -7
  85. data/test/commands_on_lists_test.rb +0 -7
  86. data/test/commands_on_sets_test.rb +0 -7
  87. data/test/commands_on_sorted_sets_test.rb +0 -7
  88. data/test/commands_on_strings_test.rb +0 -7
  89. data/test/commands_on_value_types_test.rb +0 -207
  90. data/test/connection_handling_test.rb +0 -275
  91. data/test/connection_test.rb +0 -57
  92. data/test/db/.gitkeep +0 -0
  93. data/test/distributed_blocking_commands_test.rb +0 -52
  94. data/test/distributed_commands_on_hashes_test.rb +0 -21
  95. data/test/distributed_commands_on_hyper_log_log_test.rb +0 -26
  96. data/test/distributed_commands_on_lists_test.rb +0 -19
  97. data/test/distributed_commands_on_sets_test.rb +0 -105
  98. data/test/distributed_commands_on_sorted_sets_test.rb +0 -59
  99. data/test/distributed_commands_on_strings_test.rb +0 -79
  100. data/test/distributed_commands_on_value_types_test.rb +0 -129
  101. data/test/distributed_commands_requiring_clustering_test.rb +0 -162
  102. data/test/distributed_connection_handling_test.rb +0 -21
  103. data/test/distributed_internals_test.rb +0 -68
  104. data/test/distributed_key_tags_test.rb +0 -50
  105. data/test/distributed_persistence_control_commands_test.rb +0 -24
  106. data/test/distributed_publish_subscribe_test.rb +0 -90
  107. data/test/distributed_remote_server_control_commands_test.rb +0 -64
  108. data/test/distributed_scripting_test.rb +0 -100
  109. data/test/distributed_sorting_test.rb +0 -18
  110. data/test/distributed_test.rb +0 -56
  111. data/test/distributed_transactions_test.rb +0 -30
  112. data/test/encoding_test.rb +0 -14
  113. data/test/error_replies_test.rb +0 -57
  114. data/test/fork_safety_test.rb +0 -60
  115. data/test/helper.rb +0 -345
  116. data/test/helper_test.rb +0 -22
  117. data/test/internals_test.rb +0 -408
  118. data/test/lint/blocking_commands.rb +0 -174
  119. data/test/lint/hashes.rb +0 -203
  120. data/test/lint/hyper_log_log.rb +0 -74
  121. data/test/lint/lists.rb +0 -159
  122. data/test/lint/sets.rb +0 -282
  123. data/test/lint/sorted_sets.rb +0 -497
  124. data/test/lint/strings.rb +0 -348
  125. data/test/lint/value_types.rb +0 -130
  126. data/test/persistence_control_commands_test.rb +0 -24
  127. data/test/pipelining_commands_test.rb +0 -246
  128. data/test/publish_subscribe_test.rb +0 -280
  129. data/test/remote_server_control_commands_test.rb +0 -175
  130. data/test/scanning_test.rb +0 -407
  131. data/test/scripting_test.rb +0 -76
  132. data/test/sentinel_command_test.rb +0 -78
  133. data/test/sentinel_test.rb +0 -253
  134. data/test/sorting_test.rb +0 -57
  135. data/test/ssl_test.rb +0 -69
  136. data/test/support/cluster/orchestrator.rb +0 -199
  137. data/test/support/connection/hiredis.rb +0 -1
  138. data/test/support/connection/ruby.rb +0 -1
  139. data/test/support/connection/synchrony.rb +0 -17
  140. data/test/support/redis_mock.rb +0 -130
  141. data/test/support/ssl/gen_certs.sh +0 -31
  142. data/test/support/ssl/trusted-ca.crt +0 -25
  143. data/test/support/ssl/trusted-ca.key +0 -27
  144. data/test/support/ssl/trusted-cert.crt +0 -81
  145. data/test/support/ssl/trusted-cert.key +0 -28
  146. data/test/support/ssl/untrusted-ca.crt +0 -26
  147. data/test/support/ssl/untrusted-ca.key +0 -27
  148. data/test/support/ssl/untrusted-cert.crt +0 -82
  149. data/test/support/ssl/untrusted-cert.key +0 -28
  150. data/test/support/wire/synchrony.rb +0 -24
  151. data/test/support/wire/thread.rb +0 -5
  152. data/test/synchrony_driver.rb +0 -85
  153. data/test/test.conf.erb +0 -9
  154. data/test/thread_safety_test.rb +0 -60
  155. data/test/transactions_test.rb +0 -272
  156. data/test/unknown_commands_test.rb +0 -12
  157. data/test/url_param_test.rb +0 -136
@@ -1,52 +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
-
45
- def test_bzpopmin
46
- # Not implemented yet
47
- end
48
-
49
- def test_bzpopmax
50
- # Not implemented yet
51
- end
52
- end
@@ -1,21 +0,0 @@
1
- require_relative 'helper'
2
- require_relative 'lint/hashes'
3
-
4
- class TestDistributedCommandsOnHashes < Test::Unit::TestCase
5
- include Helper::Distributed
6
- include Lint::Hashes
7
-
8
- def test_hscan
9
- # Not implemented yet
10
- end
11
-
12
- def test_hstrlen
13
- # Not implemented yet
14
- end
15
-
16
- def test_mapped_hmget_in_a_pipeline_returns_hash
17
- assert_raise(Redis::Distributed::CannotDistribute) do
18
- super
19
- end
20
- end
21
- end
@@ -1,26 +0,0 @@
1
- require_relative 'helper'
2
- require_relative 'lint/hyper_log_log'
3
-
4
- class TestDistributedCommandsOnHyperLogLog < Test::Unit::TestCase
5
- include Helper::Distributed
6
- include Lint::HyperLogLog
7
-
8
- def test_pfmerge
9
- target_version '2.8.9' do
10
- assert_raise Redis::Distributed::CannotDistribute do
11
- super
12
- end
13
- end
14
- end
15
-
16
- def test_pfcount_multiple_keys_diff_nodes
17
- target_version '2.8.9' do
18
- assert_raise Redis::Distributed::CannotDistribute do
19
- r.pfadd 'foo', 's1'
20
- r.pfadd 'bar', 's2'
21
-
22
- assert r.pfcount('res', 'foo', 'bar')
23
- end
24
- end
25
- end
26
- end
@@ -1,19 +0,0 @@
1
- require_relative 'helper'
2
- require_relative 'lint/lists'
3
-
4
- class TestDistributedCommandsOnLists < Test::Unit::TestCase
5
- include Helper::Distributed
6
- include Lint::Lists
7
-
8
- def test_rpoplpush
9
- assert_raise Redis::Distributed::CannotDistribute do
10
- r.rpoplpush('foo', 'bar')
11
- end
12
- end
13
-
14
- def test_brpoplpush
15
- assert_raise Redis::Distributed::CannotDistribute do
16
- r.brpoplpush('foo', 'bar', timeout: 1)
17
- end
18
- end
19
- end
@@ -1,105 +0,0 @@
1
- require_relative 'helper'
2
- require_relative 'lint/sets'
3
-
4
- class TestDistributedCommandsOnSets < Test::Unit::TestCase
5
- include Helper::Distributed
6
- include Lint::Sets
7
-
8
- def test_smove
9
- assert_raise Redis::Distributed::CannotDistribute do
10
- r.sadd 'foo', 's1'
11
- r.sadd 'bar', 's2'
12
-
13
- r.smove('foo', 'bar', 's1')
14
- end
15
- end
16
-
17
- def test_sinter
18
- assert_raise Redis::Distributed::CannotDistribute do
19
- r.sadd 'foo', 's1'
20
- r.sadd 'foo', 's2'
21
- r.sadd 'bar', 's2'
22
-
23
- r.sinter('foo', 'bar')
24
- end
25
- end
26
-
27
- def test_sinterstore
28
- assert_raise Redis::Distributed::CannotDistribute do
29
- r.sadd 'foo', 's1'
30
- r.sadd 'foo', 's2'
31
- r.sadd 'bar', 's2'
32
-
33
- r.sinterstore('baz', 'foo', 'bar')
34
- end
35
- end
36
-
37
- def test_sunion
38
- assert_raise Redis::Distributed::CannotDistribute do
39
- r.sadd 'foo', 's1'
40
- r.sadd 'foo', 's2'
41
- r.sadd 'bar', 's2'
42
- r.sadd 'bar', 's3'
43
-
44
- r.sunion('foo', 'bar')
45
- end
46
- end
47
-
48
- def test_sunionstore
49
- assert_raise Redis::Distributed::CannotDistribute do
50
- r.sadd 'foo', 's1'
51
- r.sadd 'foo', 's2'
52
- r.sadd 'bar', 's2'
53
- r.sadd 'bar', 's3'
54
-
55
- r.sunionstore('baz', 'foo', 'bar')
56
- end
57
- end
58
-
59
- def test_sdiff
60
- assert_raise Redis::Distributed::CannotDistribute do
61
- r.sadd 'foo', 's1'
62
- r.sadd 'foo', 's2'
63
- r.sadd 'bar', 's2'
64
- r.sadd 'bar', 's3'
65
-
66
- r.sdiff('foo', 'bar')
67
- end
68
- end
69
-
70
- def test_sdiffstore
71
- assert_raise Redis::Distributed::CannotDistribute do
72
- r.sadd 'foo', 's1'
73
- r.sadd 'foo', 's2'
74
- r.sadd 'bar', 's2'
75
- r.sadd 'bar', 's3'
76
-
77
- r.sdiffstore('baz', 'foo', 'bar')
78
- end
79
- end
80
-
81
- def test_sscan
82
- assert_nothing_raised do
83
- r.sadd 'foo', 's1'
84
- r.sadd 'foo', 's2'
85
- r.sadd 'bar', 's2'
86
- r.sadd 'bar', 's3'
87
-
88
- cursor, vals = r.sscan 'foo', 0
89
- assert_equal '0', cursor
90
- assert_equal %w[s1 s2], vals.sort
91
- end
92
- end
93
-
94
- def test_sscan_each
95
- assert_nothing_raised do
96
- r.sadd 'foo', 's1'
97
- r.sadd 'foo', 's2'
98
- r.sadd 'bar', 's2'
99
- r.sadd 'bar', 's3'
100
-
101
- vals = r.sscan_each('foo').to_a
102
- assert_equal %w[s1 s2], vals.sort
103
- end
104
- end
105
- end
@@ -1,59 +0,0 @@
1
- require_relative 'helper'
2
- require_relative 'lint/sorted_sets'
3
-
4
- class TestDistributedCommandsOnSortedSets < Test::Unit::TestCase
5
- include Helper::Distributed
6
- include Lint::SortedSets
7
-
8
- def test_zinterstore
9
- assert_raise(Redis::Distributed::CannotDistribute) { super }
10
- end
11
-
12
- def test_zinterstore_with_aggregate
13
- assert_raise(Redis::Distributed::CannotDistribute) { super }
14
- end
15
-
16
- def test_zinterstore_with_weights
17
- assert_raise(Redis::Distributed::CannotDistribute) { super }
18
- end
19
-
20
- def test_zlexcount
21
- # Not implemented yet
22
- end
23
-
24
- def test_zpopmax
25
- # Not implemented yet
26
- end
27
-
28
- def test_zpopmin
29
- # Not implemented yet
30
- end
31
-
32
- def test_zrangebylex
33
- # Not implemented yet
34
- end
35
-
36
- def test_zremrangebylex
37
- # Not implemented yet
38
- end
39
-
40
- def test_zrevrangebylex
41
- # Not implemented yet
42
- end
43
-
44
- def test_zscan
45
- # Not implemented yet
46
- end
47
-
48
- def test_zunionstore
49
- assert_raise(Redis::Distributed::CannotDistribute) { super }
50
- end
51
-
52
- def test_zunionstore_with_aggregate
53
- assert_raise(Redis::Distributed::CannotDistribute) { super }
54
- end
55
-
56
- def test_zunionstore_with_weights
57
- assert_raise(Redis::Distributed::CannotDistribute) { super }
58
- end
59
- end
@@ -1,79 +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
-
70
- def test_mapped_mget_in_a_pipeline_returns_hash
71
- assert_raise Redis::Distributed::CannotDistribute do
72
- super
73
- end
74
- end
75
-
76
- def test_bitfield
77
- # Not implemented yet
78
- end
79
- end
@@ -1,129 +0,0 @@
1
- require_relative "helper"
2
- require_relative "lint/value_types"
3
-
4
- class TestDistributedCommandsOnValueTypes < Test::Unit::TestCase
5
-
6
- include Helper::Distributed
7
- include Lint::ValueTypes
8
-
9
- def test_del
10
- r.set "foo", "s1"
11
- r.set "bar", "s2"
12
- r.set "baz", "s3"
13
-
14
- assert_equal ["bar", "baz", "foo"], r.keys("*").sort
15
-
16
- assert_equal 1, r.del("foo")
17
-
18
- assert_equal ["bar", "baz"], r.keys("*").sort
19
-
20
- assert_equal 2, r.del("bar", "baz")
21
-
22
- assert_equal [], r.keys("*").sort
23
- end
24
-
25
- def test_del_with_array_argument
26
- r.set "foo", "s1"
27
- r.set "bar", "s2"
28
- r.set "baz", "s3"
29
-
30
- assert_equal ["bar", "baz", "foo"], r.keys("*").sort
31
-
32
- assert_equal 1, r.del(["foo"])
33
-
34
- assert_equal ["bar", "baz"], r.keys("*").sort
35
-
36
- assert_equal 2, r.del(["bar", "baz"])
37
-
38
- assert_equal [], r.keys("*").sort
39
- end
40
-
41
- def test_unlink
42
- target_version "4.0.0" do
43
- r.set "foo", "s1"
44
- r.set "bar", "s2"
45
- r.set "baz", "s3"
46
-
47
- assert_equal ["bar", "baz", "foo"], r.keys("*").sort
48
-
49
- assert_equal 1, r.unlink("foo")
50
-
51
- assert_equal ["bar", "baz"], r.keys("*").sort
52
-
53
- assert_equal 2, r.unlink("bar", "baz")
54
-
55
- assert_equal [], r.keys("*").sort
56
- end
57
- end
58
-
59
- def test_unlink_with_array_argument
60
- target_version "4.0.0" do
61
- r.set "foo", "s1"
62
- r.set "bar", "s2"
63
- r.set "baz", "s3"
64
-
65
- assert_equal ["bar", "baz", "foo"], r.keys("*").sort
66
-
67
- assert_equal 1, r.unlink(["foo"])
68
-
69
- assert_equal ["bar", "baz"], r.keys("*").sort
70
-
71
- assert_equal 2, r.unlink(["bar", "baz"])
72
-
73
- assert_equal [], r.keys("*").sort
74
- end
75
- end
76
-
77
- def test_randomkey
78
- assert_raise Redis::Distributed::CannotDistribute do
79
- r.randomkey
80
- end
81
- end
82
-
83
- def test_rename
84
- assert_raise Redis::Distributed::CannotDistribute do
85
- r.set("foo", "s1")
86
- r.rename "foo", "bar"
87
- end
88
-
89
- assert_equal "s1", r.get("foo")
90
- assert_equal nil, r.get("bar")
91
- end
92
-
93
- def test_renamenx
94
- assert_raise Redis::Distributed::CannotDistribute do
95
- r.set("foo", "s1")
96
- r.rename "foo", "bar"
97
- end
98
-
99
- assert_equal "s1", r.get("foo")
100
- assert_equal nil , r.get("bar")
101
- end
102
-
103
- def test_dbsize
104
- assert_equal [0], r.dbsize
105
-
106
- r.set("foo", "s1")
107
-
108
- assert_equal [1], r.dbsize
109
- end
110
-
111
- def test_flushdb
112
- r.set("foo", "s1")
113
- r.set("bar", "s2")
114
-
115
- assert_equal [2], r.dbsize
116
-
117
- r.flushdb
118
-
119
- assert_equal [0], r.dbsize
120
- end
121
-
122
- def test_migrate
123
- r.set("foo", "s1")
124
-
125
- assert_raise Redis::Distributed::CannotDistribute do
126
- r.migrate("foo", {})
127
- end
128
- end
129
- end
@@ -1,162 +0,0 @@
1
- require_relative "helper"
2
-
3
- class TestDistributedCommandsRequiringClustering < Test::Unit::TestCase
4
-
5
- include Helper::Distributed
6
-
7
- def test_rename
8
- r.set("{qux}foo", "s1")
9
- r.rename "{qux}foo", "{qux}bar"
10
-
11
- assert_equal "s1", r.get("{qux}bar")
12
- assert_equal nil, r.get("{qux}foo")
13
- end
14
-
15
- def test_renamenx
16
- r.set("{qux}foo", "s1")
17
- r.set("{qux}bar", "s2")
18
-
19
- assert_equal false, r.renamenx("{qux}foo", "{qux}bar")
20
-
21
- assert_equal "s1", r.get("{qux}foo")
22
- assert_equal "s2", r.get("{qux}bar")
23
- end
24
-
25
- def test_brpoplpush
26
- r.rpush "{qux}foo", "s1"
27
- r.rpush "{qux}foo", "s2"
28
-
29
- assert_equal "s2", r.brpoplpush("{qux}foo", "{qux}bar", :timeout => 1)
30
- assert_equal ["s2"], r.lrange("{qux}bar", 0, -1)
31
- end
32
-
33
- def test_rpoplpush
34
- r.rpush "{qux}foo", "s1"
35
- r.rpush "{qux}foo", "s2"
36
-
37
- assert_equal "s2", r.rpoplpush("{qux}foo", "{qux}bar")
38
- assert_equal ["s2"], r.lrange("{qux}bar", 0, -1)
39
- assert_equal "s1", r.rpoplpush("{qux}foo", "{qux}bar")
40
- assert_equal ["s1", "s2"], r.lrange("{qux}bar", 0, -1)
41
- end
42
-
43
- def test_smove
44
- r.sadd "{qux}foo", "s1"
45
- r.sadd "{qux}bar", "s2"
46
-
47
- assert r.smove("{qux}foo", "{qux}bar", "s1")
48
- assert r.sismember("{qux}bar", "s1")
49
- end
50
-
51
- def test_sinter
52
- r.sadd "{qux}foo", "s1"
53
- r.sadd "{qux}foo", "s2"
54
- r.sadd "{qux}bar", "s2"
55
-
56
- assert_equal ["s2"], r.sinter("{qux}foo", "{qux}bar")
57
- end
58
-
59
- def test_sinterstore
60
- r.sadd "{qux}foo", "s1"
61
- r.sadd "{qux}foo", "s2"
62
- r.sadd "{qux}bar", "s2"
63
-
64
- r.sinterstore("{qux}baz", "{qux}foo", "{qux}bar")
65
-
66
- assert_equal ["s2"], r.smembers("{qux}baz")
67
- end
68
-
69
- def test_sunion
70
- r.sadd "{qux}foo", "s1"
71
- r.sadd "{qux}foo", "s2"
72
- r.sadd "{qux}bar", "s2"
73
- r.sadd "{qux}bar", "s3"
74
-
75
- assert_equal ["s1", "s2", "s3"], r.sunion("{qux}foo", "{qux}bar").sort
76
- end
77
-
78
- def test_sunionstore
79
- r.sadd "{qux}foo", "s1"
80
- r.sadd "{qux}foo", "s2"
81
- r.sadd "{qux}bar", "s2"
82
- r.sadd "{qux}bar", "s3"
83
-
84
- r.sunionstore("{qux}baz", "{qux}foo", "{qux}bar")
85
-
86
- assert_equal ["s1", "s2", "s3"], r.smembers("{qux}baz").sort
87
- end
88
-
89
- def test_sdiff
90
- r.sadd "{qux}foo", "s1"
91
- r.sadd "{qux}foo", "s2"
92
- r.sadd "{qux}bar", "s2"
93
- r.sadd "{qux}bar", "s3"
94
-
95
- assert_equal ["s1"], r.sdiff("{qux}foo", "{qux}bar")
96
- assert_equal ["s3"], r.sdiff("{qux}bar", "{qux}foo")
97
- end
98
-
99
- def test_sdiffstore
100
- r.sadd "{qux}foo", "s1"
101
- r.sadd "{qux}foo", "s2"
102
- r.sadd "{qux}bar", "s2"
103
- r.sadd "{qux}bar", "s3"
104
-
105
- r.sdiffstore("{qux}baz", "{qux}foo", "{qux}bar")
106
-
107
- assert_equal ["s1"], r.smembers("{qux}baz")
108
- end
109
-
110
- def test_sort
111
- r.set("{qux}foo:1", "s1")
112
- r.set("{qux}foo:2", "s2")
113
-
114
- r.rpush("{qux}bar", "1")
115
- r.rpush("{qux}bar", "2")
116
-
117
- assert_equal ["s1"], r.sort("{qux}bar", :get => "{qux}foo:*", :limit => [0, 1])
118
- assert_equal ["s2"], r.sort("{qux}bar", :get => "{qux}foo:*", :limit => [0, 1], :order => "desc alpha")
119
- end
120
-
121
- def test_sort_with_an_array_of_gets
122
- r.set("{qux}foo:1:a", "s1a")
123
- r.set("{qux}foo:1:b", "s1b")
124
-
125
- r.set("{qux}foo:2:a", "s2a")
126
- r.set("{qux}foo:2:b", "s2b")
127
-
128
- r.rpush("{qux}bar", "1")
129
- r.rpush("{qux}bar", "2")
130
-
131
- assert_equal [["s1a", "s1b"]], r.sort("{qux}bar", :get => ["{qux}foo:*:a", "{qux}foo:*:b"], :limit => [0, 1])
132
- assert_equal [["s2a", "s2b"]], r.sort("{qux}bar", :get => ["{qux}foo:*:a", "{qux}foo:*:b"], :limit => [0, 1], :order => "desc alpha")
133
- assert_equal [["s1a", "s1b"], ["s2a", "s2b"]], r.sort("{qux}bar", :get => ["{qux}foo:*:a", "{qux}foo:*:b"])
134
- end
135
-
136
- def test_sort_with_store
137
- r.set("{qux}foo:1", "s1")
138
- r.set("{qux}foo:2", "s2")
139
-
140
- r.rpush("{qux}bar", "1")
141
- r.rpush("{qux}bar", "2")
142
-
143
- r.sort("{qux}bar", :get => "{qux}foo:*", :store => "{qux}baz")
144
- assert_equal ["s1", "s2"], r.lrange("{qux}baz", 0, -1)
145
- end
146
-
147
- def test_bitop
148
- target_version "2.5.10" do
149
- r.set("{qux}foo", "a")
150
- r.set("{qux}bar", "b")
151
-
152
- r.bitop(:and, "{qux}foo&bar", "{qux}foo", "{qux}bar")
153
- assert_equal "\x60", r.get("{qux}foo&bar")
154
- r.bitop(:or, "{qux}foo|bar", "{qux}foo", "{qux}bar")
155
- assert_equal "\x63", r.get("{qux}foo|bar")
156
- r.bitop(:xor, "{qux}foo^bar", "{qux}foo", "{qux}bar")
157
- assert_equal "\x03", r.get("{qux}foo^bar")
158
- r.bitop(:not, "{qux}~foo", "{qux}foo")
159
- assert_equal "\x9E", r.get("{qux}~foo")
160
- end
161
- end
162
- end
@@ -1,21 +0,0 @@
1
- require_relative "helper"
2
-
3
- class TestDistributedConnectionHandling < Test::Unit::TestCase
4
-
5
- include Helper::Distributed
6
-
7
- def test_ping
8
- assert_equal ["PONG"], r.ping
9
- end
10
-
11
- def test_select
12
- r.set "foo", "bar"
13
-
14
- r.select 14
15
- assert_equal nil, r.get("foo")
16
-
17
- r.select 15
18
-
19
- assert_equal "bar", r.get("foo")
20
- end
21
- end