redis 3.3.5 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +32 -50
  3. data/CHANGELOG.md +7 -9
  4. data/Gemfile +0 -1
  5. data/README.md +31 -75
  6. data/benchmarking/logging.rb +1 -1
  7. data/lib/redis.rb +31 -35
  8. data/lib/redis/client.rb +13 -8
  9. data/lib/redis/connection.rb +2 -2
  10. data/lib/redis/connection/command_helper.rb +2 -8
  11. data/lib/redis/connection/hiredis.rb +2 -2
  12. data/lib/redis/connection/ruby.rb +7 -27
  13. data/lib/redis/connection/synchrony.rb +3 -3
  14. data/lib/redis/pipeline.rb +0 -6
  15. data/lib/redis/version.rb +1 -1
  16. data/makefile +42 -0
  17. data/redis.gemspec +4 -8
  18. data/test/bitpos_test.rb +13 -19
  19. data/test/blocking_commands_test.rb +147 -6
  20. data/test/client_test.rb +1 -1
  21. data/test/command_map_test.rb +3 -5
  22. data/test/commands_on_hashes_test.rb +158 -5
  23. data/test/commands_on_hyper_log_log_test.rb +55 -6
  24. data/test/commands_on_lists_test.rb +139 -5
  25. data/test/commands_on_sets_test.rb +136 -5
  26. data/test/commands_on_sorted_sets_test.rb +312 -5
  27. data/test/commands_on_strings_test.rb +243 -6
  28. data/test/commands_on_value_types_test.rb +120 -7
  29. data/test/connection_handling_test.rb +5 -7
  30. data/test/encoding_test.rb +4 -8
  31. data/test/error_replies_test.rb +2 -4
  32. data/test/fork_safety_test.rb +1 -6
  33. data/test/helper.rb +9 -62
  34. data/test/helper_test.rb +1 -3
  35. data/test/internals_test.rb +67 -49
  36. data/test/persistence_control_commands_test.rb +1 -3
  37. data/test/pipelining_commands_test.rb +4 -8
  38. data/test/publish_subscribe_test.rb +1 -3
  39. data/test/remote_server_control_commands_test.rb +61 -4
  40. data/test/scanning_test.rb +1 -7
  41. data/test/scripting_test.rb +1 -3
  42. data/test/sentinel_command_test.rb +1 -3
  43. data/test/sentinel_test.rb +1 -3
  44. data/test/sorting_test.rb +1 -3
  45. data/test/ssl_test.rb +45 -49
  46. data/test/support/connection/hiredis.rb +1 -1
  47. data/test/support/connection/ruby.rb +1 -1
  48. data/test/support/connection/synchrony.rb +1 -1
  49. data/test/synchrony_driver.rb +6 -9
  50. data/test/thread_safety_test.rb +1 -3
  51. data/test/transactions_test.rb +1 -3
  52. data/test/unknown_commands_test.rb +1 -3
  53. data/test/url_param_test.rb +44 -46
  54. metadata +31 -77
  55. data/Rakefile +0 -87
  56. data/examples/dist_redis.rb +0 -43
  57. data/lib/redis/distributed.rb +0 -873
  58. data/lib/redis/hash_ring.rb +0 -132
  59. data/test/connection_test.rb +0 -57
  60. data/test/distributed_blocking_commands_test.rb +0 -46
  61. data/test/distributed_commands_on_hashes_test.rb +0 -10
  62. data/test/distributed_commands_on_hyper_log_log_test.rb +0 -33
  63. data/test/distributed_commands_on_lists_test.rb +0 -22
  64. data/test/distributed_commands_on_sets_test.rb +0 -83
  65. data/test/distributed_commands_on_sorted_sets_test.rb +0 -18
  66. data/test/distributed_commands_on_strings_test.rb +0 -59
  67. data/test/distributed_commands_on_value_types_test.rb +0 -95
  68. data/test/distributed_commands_requiring_clustering_test.rb +0 -164
  69. data/test/distributed_connection_handling_test.rb +0 -23
  70. data/test/distributed_internals_test.rb +0 -79
  71. data/test/distributed_key_tags_test.rb +0 -52
  72. data/test/distributed_persistence_control_commands_test.rb +0 -26
  73. data/test/distributed_publish_subscribe_test.rb +0 -92
  74. data/test/distributed_remote_server_control_commands_test.rb +0 -66
  75. data/test/distributed_scripting_test.rb +0 -102
  76. data/test/distributed_sorting_test.rb +0 -20
  77. data/test/distributed_test.rb +0 -58
  78. data/test/distributed_transactions_test.rb +0 -32
  79. data/test/lint/blocking_commands.rb +0 -150
  80. data/test/lint/hashes.rb +0 -162
  81. data/test/lint/hyper_log_log.rb +0 -60
  82. data/test/lint/lists.rb +0 -143
  83. data/test/lint/sets.rb +0 -140
  84. data/test/lint/sorted_sets.rb +0 -316
  85. data/test/lint/strings.rb +0 -260
  86. data/test/lint/value_types.rb +0 -122
data/test/lint/strings.rb DELETED
@@ -1,260 +0,0 @@
1
- module Lint
2
-
3
- module Strings
4
-
5
- def test_set_and_get
6
- r.set("foo", "s1")
7
-
8
- assert_equal "s1", r.get("foo")
9
- end
10
-
11
- def test_set_and_get_with_brackets
12
- r["foo"] = "s1"
13
-
14
- assert_equal "s1", r["foo"]
15
- end
16
-
17
- def test_set_and_get_with_brackets_and_symbol
18
- r[:foo] = "s1"
19
-
20
- assert_equal "s1", r[:foo]
21
- end
22
-
23
- def test_set_and_get_with_newline_characters
24
- r.set("foo", "1\n")
25
-
26
- assert_equal "1\n", r.get("foo")
27
- end
28
-
29
- def test_set_and_get_with_non_string_value
30
- value = ["a", "b"]
31
-
32
- r.set("foo", value)
33
-
34
- assert_equal value.to_s, r.get("foo")
35
- end
36
-
37
- def test_set_and_get_with_ascii_characters
38
- if defined?(Encoding)
39
- with_external_encoding("ASCII-8BIT") do
40
- (0..255).each do |i|
41
- str = "#{i.chr}---#{i.chr}"
42
- r.set("foo", str)
43
-
44
- assert_equal str, r.get("foo")
45
- end
46
- end
47
- end
48
- end
49
-
50
- def test_set_with_ex
51
- target_version "2.6.12" do
52
- r.set("foo", "bar", :ex => 2)
53
- assert_in_range 0..2, r.ttl("foo")
54
- end
55
- end
56
-
57
- def test_set_with_px
58
- target_version "2.6.12" do
59
- r.set("foo", "bar", :px => 2000)
60
- assert_in_range 0..2, r.ttl("foo")
61
- end
62
- end
63
-
64
- def test_set_with_nx
65
- target_version "2.6.12" do
66
- r.set("foo", "qux", :nx => true)
67
- assert !r.set("foo", "bar", :nx => true)
68
- assert_equal "qux", r.get("foo")
69
-
70
- r.del("foo")
71
- assert r.set("foo", "bar", :nx => true)
72
- assert_equal "bar", r.get("foo")
73
- end
74
- end
75
-
76
- def test_set_with_xx
77
- target_version "2.6.12" do
78
- r.set("foo", "qux")
79
- assert r.set("foo", "bar", :xx => true)
80
- assert_equal "bar", r.get("foo")
81
-
82
- r.del("foo")
83
- assert !r.set("foo", "bar", :xx => true)
84
- end
85
- end
86
-
87
- def test_setex
88
- assert r.setex("foo", 1, "bar")
89
- assert_equal "bar", r.get("foo")
90
- assert [0, 1].include? r.ttl("foo")
91
- end
92
-
93
- def test_setex_with_non_string_value
94
- value = ["b", "a", "r"]
95
-
96
- assert r.setex("foo", 1, value)
97
- assert_equal value.to_s, r.get("foo")
98
- assert [0, 1].include? r.ttl("foo")
99
- end
100
-
101
- def test_psetex
102
- target_version "2.5.4" do
103
- assert r.psetex("foo", 1000, "bar")
104
- assert_equal "bar", r.get("foo")
105
- assert [0, 1].include? r.ttl("foo")
106
- end
107
- end
108
-
109
- def test_psetex_with_non_string_value
110
- target_version "2.5.4" do
111
- value = ["b", "a", "r"]
112
-
113
- assert r.psetex("foo", 1000, value)
114
- assert_equal value.to_s, r.get("foo")
115
- assert [0, 1].include? r.ttl("foo")
116
- end
117
- end
118
-
119
- def test_getset
120
- r.set("foo", "bar")
121
-
122
- assert_equal "bar", r.getset("foo", "baz")
123
- assert_equal "baz", r.get("foo")
124
- end
125
-
126
- def test_getset_with_non_string_value
127
- r.set("foo", "zap")
128
-
129
- value = ["b", "a", "r"]
130
-
131
- assert_equal "zap", r.getset("foo", value)
132
- assert_equal value.to_s, r.get("foo")
133
- end
134
-
135
- def test_setnx
136
- r.set("foo", "qux")
137
- assert !r.setnx("foo", "bar")
138
- assert_equal "qux", r.get("foo")
139
-
140
- r.del("foo")
141
- assert r.setnx("foo", "bar")
142
- assert_equal "bar", r.get("foo")
143
- end
144
-
145
- def test_setnx_with_non_string_value
146
- value = ["b", "a", "r"]
147
-
148
- r.set("foo", "qux")
149
- assert !r.setnx("foo", value)
150
- assert_equal "qux", r.get("foo")
151
-
152
- r.del("foo")
153
- assert r.setnx("foo", value)
154
- assert_equal value.to_s, r.get("foo")
155
- end
156
-
157
- def test_incr
158
- assert_equal 1, r.incr("foo")
159
- assert_equal 2, r.incr("foo")
160
- assert_equal 3, r.incr("foo")
161
- end
162
-
163
- def test_incrby
164
- assert_equal 1, r.incrby("foo", 1)
165
- assert_equal 3, r.incrby("foo", 2)
166
- assert_equal 6, r.incrby("foo", 3)
167
- end
168
-
169
- def test_incrbyfloat
170
- target_version "2.5.4" do
171
- assert_equal 1.23, r.incrbyfloat("foo", 1.23)
172
- assert_equal 2 , r.incrbyfloat("foo", 0.77)
173
- assert_equal 1.9 , r.incrbyfloat("foo", -0.1)
174
- end
175
- end
176
-
177
- def test_decr
178
- r.set("foo", 3)
179
-
180
- assert_equal 2, r.decr("foo")
181
- assert_equal 1, r.decr("foo")
182
- assert_equal 0, r.decr("foo")
183
- end
184
-
185
- def test_decrby
186
- r.set("foo", 6)
187
-
188
- assert_equal 3, r.decrby("foo", 3)
189
- assert_equal 1, r.decrby("foo", 2)
190
- assert_equal 0, r.decrby("foo", 1)
191
- end
192
-
193
- def test_append
194
- r.set "foo", "s"
195
- r.append "foo", "1"
196
-
197
- assert_equal "s1", r.get("foo")
198
- end
199
-
200
- def test_getbit
201
- r.set("foo", "a")
202
-
203
- assert_equal 1, r.getbit("foo", 1)
204
- assert_equal 1, r.getbit("foo", 2)
205
- assert_equal 0, r.getbit("foo", 3)
206
- assert_equal 0, r.getbit("foo", 4)
207
- assert_equal 0, r.getbit("foo", 5)
208
- assert_equal 0, r.getbit("foo", 6)
209
- assert_equal 1, r.getbit("foo", 7)
210
- end
211
-
212
- def test_setbit
213
- r.set("foo", "a")
214
-
215
- r.setbit("foo", 6, 1)
216
-
217
- assert_equal "c", r.get("foo")
218
- end
219
-
220
- def test_bitcount
221
- target_version "2.5.10" do
222
- r.set("foo", "abcde")
223
-
224
- assert_equal 10, r.bitcount("foo", 1, 3)
225
- assert_equal 17, r.bitcount("foo", 0, -1)
226
- end
227
- end
228
-
229
- def test_getrange
230
- r.set("foo", "abcde")
231
-
232
- assert_equal "bcd", r.getrange("foo", 1, 3)
233
- assert_equal "abcde", r.getrange("foo", 0, -1)
234
- end
235
-
236
- def test_setrange
237
- r.set("foo", "abcde")
238
-
239
- r.setrange("foo", 1, "bar")
240
-
241
- assert_equal "abare", r.get("foo")
242
- end
243
-
244
- def test_setrange_with_non_string_value
245
- r.set("foo", "abcde")
246
-
247
- value = ["b", "a", "r"]
248
-
249
- r.setrange("foo", 2, value)
250
-
251
- assert_equal "ab#{value.to_s}", r.get("foo")
252
- end
253
-
254
- def test_strlen
255
- r.set "foo", "lorem"
256
-
257
- assert_equal 5, r.strlen("foo")
258
- end
259
- end
260
- end
@@ -1,122 +0,0 @@
1
- module Lint
2
-
3
- module ValueTypes
4
-
5
- def test_exists
6
- assert_equal false, r.exists("foo")
7
-
8
- r.set("foo", "s1")
9
-
10
- assert_equal true, r.exists("foo")
11
- end
12
-
13
- def test_type
14
- assert_equal "none", r.type("foo")
15
-
16
- r.set("foo", "s1")
17
-
18
- assert_equal "string", r.type("foo")
19
- end
20
-
21
- def test_keys
22
- r.set("f", "s1")
23
- r.set("fo", "s2")
24
- r.set("foo", "s3")
25
-
26
- assert_equal ["f","fo", "foo"], r.keys("f*").sort
27
- end
28
-
29
- def test_expire
30
- r.set("foo", "s1")
31
- assert r.expire("foo", 2)
32
- assert_in_range 0..2, r.ttl("foo")
33
- end
34
-
35
- def test_pexpire
36
- target_version "2.5.4" do
37
- r.set("foo", "s1")
38
- assert r.pexpire("foo", 2000)
39
- assert_in_range 0..2, r.ttl("foo")
40
- end
41
- end
42
-
43
- def test_expireat
44
- r.set("foo", "s1")
45
- assert r.expireat("foo", (Time.now + 2).to_i)
46
- assert_in_range 0..2, r.ttl("foo")
47
- end
48
-
49
- def test_pexpireat
50
- target_version "2.5.4" do
51
- r.set("foo", "s1")
52
- assert r.pexpireat("foo", (Time.now + 2).to_i * 1_000)
53
- assert_in_range 0..2, r.ttl("foo")
54
- end
55
- end
56
-
57
- def test_persist
58
- r.set("foo", "s1")
59
- r.expire("foo", 1)
60
- r.persist("foo")
61
-
62
- assert(-1 == r.ttl("foo"))
63
- end
64
-
65
- def test_ttl
66
- r.set("foo", "s1")
67
- r.expire("foo", 2)
68
- assert_in_range 0..2, r.ttl("foo")
69
- end
70
-
71
- def test_pttl
72
- target_version "2.5.4" do
73
- r.set("foo", "s1")
74
- r.expire("foo", 2)
75
- assert_in_range 1..2000, r.pttl("foo")
76
- end
77
- end
78
-
79
- def test_dump_and_restore
80
- target_version "2.5.7" do
81
- r.set("foo", "a")
82
- v = r.dump("foo")
83
- r.del("foo")
84
-
85
- assert r.restore("foo", 1000, v)
86
- assert_equal "a", r.get("foo")
87
- assert [0, 1].include? r.ttl("foo")
88
-
89
- r.rpush("bar", ["b", "c", "d"])
90
- w = r.dump("bar")
91
- r.del("bar")
92
-
93
- assert r.restore("bar", 1000, w)
94
- assert_equal ["b", "c", "d"], r.lrange("bar", 0, -1)
95
- assert [0, 1].include? r.ttl("bar")
96
- end
97
- end
98
-
99
- def test_move
100
- r.select 14
101
- r.flushdb
102
-
103
- r.set "bar", "s3"
104
-
105
- r.select 15
106
-
107
- r.set "foo", "s1"
108
- r.set "bar", "s2"
109
-
110
- assert r.move("foo", 14)
111
- assert_equal nil, r.get("foo")
112
-
113
- assert !r.move("bar", 14)
114
- assert_equal "s2", r.get("bar")
115
-
116
- r.select 14
117
-
118
- assert_equal "s1", r.get("foo")
119
- assert_equal "s3", r.get("bar")
120
- end
121
- end
122
- end