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
data/test/lint/strings.rb DELETED
@@ -1,348 +0,0 @@
1
- module Lint
2
-
3
- module Strings
4
- def mock(*args, &block)
5
- redis_mock(*args, &block)
6
- end
7
-
8
- def test_set_and_get
9
- r.set("foo", "s1")
10
-
11
- assert_equal "s1", r.get("foo")
12
- end
13
-
14
- def test_set_and_get_with_newline_characters
15
- r.set("foo", "1\n")
16
-
17
- assert_equal "1\n", r.get("foo")
18
- end
19
-
20
- def test_set_and_get_with_non_string_value
21
- value = ["a", "b"]
22
-
23
- r.set("foo", value)
24
-
25
- assert_equal value.to_s, r.get("foo")
26
- end
27
-
28
- def test_set_and_get_with_ascii_characters
29
- with_external_encoding("ASCII-8BIT") do
30
- (0..255).each do |i|
31
- str = "#{i.chr}---#{i.chr}"
32
- r.set("foo", str)
33
-
34
- assert_equal str, r.get("foo")
35
- end
36
- end
37
- end
38
-
39
- def test_set_with_ex
40
- target_version "2.6.12" do
41
- r.set("foo", "bar", :ex => 2)
42
- assert_in_range 0..2, r.ttl("foo")
43
- end
44
- end
45
-
46
- def test_set_with_px
47
- target_version "2.6.12" do
48
- r.set("foo", "bar", :px => 2000)
49
- assert_in_range 0..2, r.ttl("foo")
50
- end
51
- end
52
-
53
- def test_set_with_nx
54
- target_version "2.6.12" do
55
- r.set("foo", "qux", :nx => true)
56
- assert !r.set("foo", "bar", :nx => true)
57
- assert_equal "qux", r.get("foo")
58
-
59
- r.del("foo")
60
- assert r.set("foo", "bar", :nx => true)
61
- assert_equal "bar", r.get("foo")
62
- end
63
- end
64
-
65
- def test_set_with_xx
66
- target_version "2.6.12" do
67
- r.set("foo", "qux")
68
- assert r.set("foo", "bar", :xx => true)
69
- assert_equal "bar", r.get("foo")
70
-
71
- r.del("foo")
72
- assert !r.set("foo", "bar", :xx => true)
73
- end
74
- end
75
-
76
- def test_setex
77
- assert r.setex("foo", 1, "bar")
78
- assert_equal "bar", r.get("foo")
79
- assert [0, 1].include? r.ttl("foo")
80
- end
81
-
82
- def test_setex_with_non_string_value
83
- value = ["b", "a", "r"]
84
-
85
- assert r.setex("foo", 1, value)
86
- assert_equal value.to_s, r.get("foo")
87
- assert [0, 1].include? r.ttl("foo")
88
- end
89
-
90
- def test_psetex
91
- target_version "2.5.4" do
92
- assert r.psetex("foo", 1000, "bar")
93
- assert_equal "bar", r.get("foo")
94
- assert [0, 1].include? r.ttl("foo")
95
- end
96
- end
97
-
98
- def test_psetex_with_non_string_value
99
- target_version "2.5.4" do
100
- value = ["b", "a", "r"]
101
-
102
- assert r.psetex("foo", 1000, value)
103
- assert_equal value.to_s, r.get("foo")
104
- assert [0, 1].include? r.ttl("foo")
105
- end
106
- end
107
-
108
- def test_getset
109
- r.set("foo", "bar")
110
-
111
- assert_equal "bar", r.getset("foo", "baz")
112
- assert_equal "baz", r.get("foo")
113
- end
114
-
115
- def test_getset_with_non_string_value
116
- r.set("foo", "zap")
117
-
118
- value = ["b", "a", "r"]
119
-
120
- assert_equal "zap", r.getset("foo", value)
121
- assert_equal value.to_s, r.get("foo")
122
- end
123
-
124
- def test_setnx
125
- r.set("foo", "qux")
126
- assert !r.setnx("foo", "bar")
127
- assert_equal "qux", r.get("foo")
128
-
129
- r.del("foo")
130
- assert r.setnx("foo", "bar")
131
- assert_equal "bar", r.get("foo")
132
- end
133
-
134
- def test_setnx_with_non_string_value
135
- value = ["b", "a", "r"]
136
-
137
- r.set("foo", "qux")
138
- assert !r.setnx("foo", value)
139
- assert_equal "qux", r.get("foo")
140
-
141
- r.del("foo")
142
- assert r.setnx("foo", value)
143
- assert_equal value.to_s, r.get("foo")
144
- end
145
-
146
- def test_incr
147
- assert_equal 1, r.incr("foo")
148
- assert_equal 2, r.incr("foo")
149
- assert_equal 3, r.incr("foo")
150
- end
151
-
152
- def test_incrby
153
- assert_equal 1, r.incrby("foo", 1)
154
- assert_equal 3, r.incrby("foo", 2)
155
- assert_equal 6, r.incrby("foo", 3)
156
- end
157
-
158
- def test_incrbyfloat
159
- target_version "2.5.4" do
160
- assert_equal 1.23, r.incrbyfloat("foo", 1.23)
161
- assert_equal 2 , r.incrbyfloat("foo", 0.77)
162
- assert_equal 1.9 , r.incrbyfloat("foo", -0.1)
163
- end
164
- end
165
-
166
- def test_decr
167
- r.set("foo", 3)
168
-
169
- assert_equal 2, r.decr("foo")
170
- assert_equal 1, r.decr("foo")
171
- assert_equal 0, r.decr("foo")
172
- end
173
-
174
- def test_decrby
175
- r.set("foo", 6)
176
-
177
- assert_equal 3, r.decrby("foo", 3)
178
- assert_equal 1, r.decrby("foo", 2)
179
- assert_equal 0, r.decrby("foo", 1)
180
- end
181
-
182
- def test_append
183
- r.set "foo", "s"
184
- r.append "foo", "1"
185
-
186
- assert_equal "s1", r.get("foo")
187
- end
188
-
189
- def test_getbit
190
- r.set("foo", "a")
191
-
192
- assert_equal 1, r.getbit("foo", 1)
193
- assert_equal 1, r.getbit("foo", 2)
194
- assert_equal 0, r.getbit("foo", 3)
195
- assert_equal 0, r.getbit("foo", 4)
196
- assert_equal 0, r.getbit("foo", 5)
197
- assert_equal 0, r.getbit("foo", 6)
198
- assert_equal 1, r.getbit("foo", 7)
199
- end
200
-
201
- def test_setbit
202
- r.set("foo", "a")
203
-
204
- r.setbit("foo", 6, 1)
205
-
206
- assert_equal "c", r.get("foo")
207
- end
208
-
209
- def test_bitcount
210
- target_version "2.5.10" do
211
- r.set("foo", "abcde")
212
-
213
- assert_equal 10, r.bitcount("foo", 1, 3)
214
- assert_equal 17, r.bitcount("foo", 0, -1)
215
- end
216
- end
217
-
218
- def test_getrange
219
- r.set("foo", "abcde")
220
-
221
- assert_equal "bcd", r.getrange("foo", 1, 3)
222
- assert_equal "abcde", r.getrange("foo", 0, -1)
223
- end
224
-
225
- def test_setrange
226
- r.set("foo", "abcde")
227
-
228
- r.setrange("foo", 1, "bar")
229
-
230
- assert_equal "abare", r.get("foo")
231
- end
232
-
233
- def test_setrange_with_non_string_value
234
- r.set("foo", "abcde")
235
-
236
- value = ["b", "a", "r"]
237
-
238
- r.setrange("foo", 2, value)
239
-
240
- assert_equal "ab#{value.to_s}", r.get("foo")
241
- end
242
-
243
- def test_strlen
244
- r.set "foo", "lorem"
245
-
246
- assert_equal 5, r.strlen("foo")
247
- end
248
-
249
- def test_bitfield
250
- target_version('3.2.0') do
251
- mock(bitfield: ->(*_) { "*2\r\n:1\r\n:0\r\n" }) do |redis|
252
- assert_equal [1, 0], redis.bitfield('foo', 'INCRBY', 'i5', 100, 1, 'GET', 'u4', 0)
253
- end
254
- end
255
- end
256
-
257
- def test_mget
258
- r.set('{1}foo', 's1')
259
- r.set('{1}bar', 's2')
260
-
261
- assert_equal %w[s1 s2], r.mget('{1}foo', '{1}bar')
262
- assert_equal ['s1', 's2', nil], r.mget('{1}foo', '{1}bar', '{1}baz')
263
- end
264
-
265
- def test_mget_mapped
266
- r.set('{1}foo', 's1')
267
- r.set('{1}bar', 's2')
268
-
269
- response = r.mapped_mget('{1}foo', '{1}bar')
270
-
271
- assert_equal 's1', response['{1}foo']
272
- assert_equal 's2', response['{1}bar']
273
-
274
- response = r.mapped_mget('{1}foo', '{1}bar', '{1}baz')
275
-
276
- assert_equal 's1', response['{1}foo']
277
- assert_equal 's2', response['{1}bar']
278
- assert_equal nil, response['{1}baz']
279
- end
280
-
281
- def test_mapped_mget_in_a_pipeline_returns_hash
282
- r.set('{1}foo', 's1')
283
- r.set('{1}bar', 's2')
284
-
285
- result = r.pipelined do
286
- r.mapped_mget('{1}foo', '{1}bar')
287
- end
288
-
289
- assert_equal({ '{1}foo' => 's1', '{1}bar' => 's2' }, result[0])
290
- end
291
-
292
- def test_mset
293
- r.mset('{1}foo', 's1', '{1}bar', 's2')
294
-
295
- assert_equal 's1', r.get('{1}foo')
296
- assert_equal 's2', r.get('{1}bar')
297
- end
298
-
299
- def test_mset_mapped
300
- r.mapped_mset('{1}foo' => 's1', '{1}bar' => 's2')
301
-
302
- assert_equal 's1', r.get('{1}foo')
303
- assert_equal 's2', r.get('{1}bar')
304
- end
305
-
306
- def test_msetnx
307
- r.set('{1}foo', 's1')
308
- assert_equal false, r.msetnx('{1}foo', 's2', '{1}bar', 's3')
309
- assert_equal 's1', r.get('{1}foo')
310
- assert_equal nil, r.get('{1}bar')
311
-
312
- r.del('{1}foo')
313
- assert_equal true, r.msetnx('{1}foo', 's2', '{1}bar', 's3')
314
- assert_equal 's2', r.get('{1}foo')
315
- assert_equal 's3', r.get('{1}bar')
316
- end
317
-
318
- def test_msetnx_mapped
319
- r.set('{1}foo', 's1')
320
- assert_equal false, r.mapped_msetnx('{1}foo' => 's2', '{1}bar' => 's3')
321
- assert_equal 's1', r.get('{1}foo')
322
- assert_equal nil, r.get('{1}bar')
323
-
324
- r.del('{1}foo')
325
- assert_equal true, r.mapped_msetnx('{1}foo' => 's2', '{1}bar' => 's3')
326
- assert_equal 's2', r.get('{1}foo')
327
- assert_equal 's3', r.get('{1}bar')
328
- end
329
-
330
- def test_bitop
331
- with_external_encoding('UTF-8') do
332
- target_version '2.5.10' do
333
- r.set('foo{1}', 'a')
334
- r.set('bar{1}', 'b')
335
-
336
- r.bitop(:and, 'foo&bar{1}', 'foo{1}', 'bar{1}')
337
- assert_equal "\x60", r.get('foo&bar{1}')
338
- r.bitop(:or, 'foo|bar{1}', 'foo{1}', 'bar{1}')
339
- assert_equal "\x63", r.get('foo|bar{1}')
340
- r.bitop(:xor, 'foo^bar{1}', 'foo{1}', 'bar{1}')
341
- assert_equal "\x03", r.get('foo^bar{1}')
342
- r.bitop(:not, '~foo{1}', 'foo{1}')
343
- assert_equal "\x9E", r.get('~foo{1}')
344
- end
345
- end
346
- end
347
- end
348
- end
@@ -1,130 +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
-
97
- r.set("bar", "somethingelse")
98
- assert_raises(Redis::CommandError) { r.restore("bar", 1000, w) } # ensure by default replace is false
99
- assert_raises(Redis::CommandError) { r.restore("bar", 1000, w, :replace => false) }
100
- assert_equal "somethingelse", r.get("bar")
101
- assert r.restore("bar", 1000, w, :replace => true)
102
- assert_equal ["b", "c", "d"], r.lrange("bar", 0, -1)
103
- assert [0, 1].include? r.ttl("bar")
104
- end
105
- end
106
-
107
- def test_move
108
- r.select 14
109
- r.flushdb
110
-
111
- r.set "bar", "s3"
112
-
113
- r.select 15
114
-
115
- r.set "foo", "s1"
116
- r.set "bar", "s2"
117
-
118
- assert r.move("foo", 14)
119
- assert_equal nil, r.get("foo")
120
-
121
- assert !r.move("bar", 14)
122
- assert_equal "s2", r.get("bar")
123
-
124
- r.select 14
125
-
126
- assert_equal "s1", r.get("foo")
127
- assert_equal "s3", r.get("bar")
128
- end
129
- end
130
- end
@@ -1,24 +0,0 @@
1
- require_relative "helper"
2
-
3
- class TestPersistenceControlCommands < Test::Unit::TestCase
4
-
5
- include Helper::Client
6
-
7
- def test_save
8
- redis_mock(:save => lambda { "+SAVE" }) do |redis|
9
- assert_equal "SAVE", redis.save
10
- end
11
- end
12
-
13
- def test_bgsave
14
- redis_mock(:bgsave => lambda { "+BGSAVE" }) do |redis|
15
- assert_equal "BGSAVE", redis.bgsave
16
- end
17
- end
18
-
19
- def test_lastsave
20
- redis_mock(:lastsave => lambda { "+LASTSAVE" }) do |redis|
21
- assert_equal "LASTSAVE", redis.lastsave
22
- end
23
- end
24
- end