redis 4.1.0.beta1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -2
- data/README.md +45 -0
- data/lib/redis.rb +497 -20
- data/lib/redis/client.rb +14 -6
- data/lib/redis/cluster.rb +1 -0
- data/lib/redis/cluster/command_loader.rb +2 -0
- data/lib/redis/cluster/node_loader.rb +2 -0
- data/lib/redis/cluster/option.rb +1 -0
- data/lib/redis/cluster/slot_loader.rb +2 -0
- data/lib/redis/distributed.rb +3 -4
- data/lib/redis/version.rb +1 -1
- metadata +20 -243
- data/.gitignore +0 -19
- data/.travis.yml +0 -61
- data/.travis/Gemfile +0 -18
- data/.yardopts +0 -3
- data/Gemfile +0 -8
- 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/bin/build +0 -71
- data/bors.toml +0 -14
- 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.rb +0 -41
- data/examples/sentinel/start +0 -49
- data/examples/sets.rb +0 -36
- data/examples/unicorn/config.ru +0 -3
- data/examples/unicorn/unicorn.rb +0 -20
- data/makefile +0 -74
- data/redis.gemspec +0 -42
- data/test/bitpos_test.rb +0 -63
- data/test/blocking_commands_test.rb +0 -40
- data/test/client_test.rb +0 -76
- data/test/cluster_abnormal_state_test.rb +0 -38
- data/test/cluster_blocking_commands_test.rb +0 -15
- data/test/cluster_client_internals_test.rb +0 -77
- data/test/cluster_client_key_hash_tags_test.rb +0 -88
- data/test/cluster_client_options_test.rb +0 -147
- data/test/cluster_client_pipelining_test.rb +0 -59
- data/test/cluster_client_replicas_test.rb +0 -36
- data/test/cluster_client_slots_test.rb +0 -94
- data/test/cluster_client_transactions_test.rb +0 -71
- data/test/cluster_commands_on_cluster_test.rb +0 -165
- data/test/cluster_commands_on_connection_test.rb +0 -40
- data/test/cluster_commands_on_geo_test.rb +0 -74
- data/test/cluster_commands_on_hashes_test.rb +0 -11
- data/test/cluster_commands_on_hyper_log_log_test.rb +0 -17
- data/test/cluster_commands_on_keys_test.rb +0 -134
- data/test/cluster_commands_on_lists_test.rb +0 -15
- data/test/cluster_commands_on_pub_sub_test.rb +0 -101
- data/test/cluster_commands_on_scripting_test.rb +0 -56
- data/test/cluster_commands_on_server_test.rb +0 -221
- data/test/cluster_commands_on_sets_test.rb +0 -39
- data/test/cluster_commands_on_sorted_sets_test.rb +0 -35
- data/test/cluster_commands_on_streams_test.rb +0 -196
- data/test/cluster_commands_on_strings_test.rb +0 -15
- data/test/cluster_commands_on_transactions_test.rb +0 -41
- data/test/cluster_commands_on_value_types_test.rb +0 -14
- data/test/command_map_test.rb +0 -28
- data/test/commands_on_geo_test.rb +0 -116
- data/test/commands_on_hashes_test.rb +0 -7
- data/test/commands_on_hyper_log_log_test.rb +0 -7
- data/test/commands_on_lists_test.rb +0 -7
- data/test/commands_on_sets_test.rb +0 -7
- data/test/commands_on_sorted_sets_test.rb +0 -7
- data/test/commands_on_strings_test.rb +0 -7
- data/test/commands_on_value_types_test.rb +0 -207
- data/test/connection_handling_test.rb +0 -275
- data/test/connection_test.rb +0 -57
- data/test/distributed_blocking_commands_test.rb +0 -52
- data/test/distributed_commands_on_hashes_test.rb +0 -21
- data/test/distributed_commands_on_hyper_log_log_test.rb +0 -26
- data/test/distributed_commands_on_lists_test.rb +0 -19
- data/test/distributed_commands_on_sets_test.rb +0 -105
- data/test/distributed_commands_on_sorted_sets_test.rb +0 -59
- data/test/distributed_commands_on_strings_test.rb +0 -79
- data/test/distributed_commands_on_value_types_test.rb +0 -129
- data/test/distributed_commands_requiring_clustering_test.rb +0 -162
- data/test/distributed_connection_handling_test.rb +0 -21
- data/test/distributed_internals_test.rb +0 -68
- data/test/distributed_key_tags_test.rb +0 -50
- data/test/distributed_persistence_control_commands_test.rb +0 -24
- data/test/distributed_publish_subscribe_test.rb +0 -90
- data/test/distributed_remote_server_control_commands_test.rb +0 -64
- data/test/distributed_scripting_test.rb +0 -100
- data/test/distributed_sorting_test.rb +0 -18
- data/test/distributed_test.rb +0 -56
- data/test/distributed_transactions_test.rb +0 -30
- data/test/encoding_test.rb +0 -14
- data/test/error_replies_test.rb +0 -57
- data/test/fork_safety_test.rb +0 -60
- data/test/helper.rb +0 -344
- data/test/helper_test.rb +0 -22
- data/test/internals_test.rb +0 -395
- data/test/lint/blocking_commands.rb +0 -174
- data/test/lint/hashes.rb +0 -203
- data/test/lint/hyper_log_log.rb +0 -74
- data/test/lint/lists.rb +0 -159
- data/test/lint/sets.rb +0 -282
- data/test/lint/sorted_sets.rb +0 -497
- data/test/lint/strings.rb +0 -348
- data/test/lint/value_types.rb +0 -130
- data/test/persistence_control_commands_test.rb +0 -24
- data/test/pipelining_commands_test.rb +0 -246
- data/test/publish_subscribe_test.rb +0 -280
- data/test/remote_server_control_commands_test.rb +0 -175
- data/test/scanning_test.rb +0 -407
- data/test/scripting_test.rb +0 -76
- data/test/sentinel_command_test.rb +0 -78
- data/test/sentinel_test.rb +0 -253
- data/test/sorting_test.rb +0 -57
- data/test/ssl_test.rb +0 -69
- data/test/support/cluster/orchestrator.rb +0 -199
- 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 -85
- data/test/test.conf.erb +0 -9
- data/test/thread_safety_test.rb +0 -60
- data/test/transactions_test.rb +0 -272
- data/test/unknown_commands_test.rb +0 -12
- 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
|
data/test/lint/value_types.rb
DELETED
@@ -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
|