redis 3.0.0 → 4.2.2
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +269 -0
- data/README.md +295 -58
- data/lib/redis.rb +1760 -451
- data/lib/redis/client.rb +355 -88
- data/lib/redis/cluster.rb +295 -0
- data/lib/redis/cluster/command.rb +81 -0
- data/lib/redis/cluster/command_loader.rb +34 -0
- data/lib/redis/cluster/key_slot_converter.rb +72 -0
- data/lib/redis/cluster/node.rb +107 -0
- data/lib/redis/cluster/node_key.rb +31 -0
- data/lib/redis/cluster/node_loader.rb +37 -0
- data/lib/redis/cluster/option.rb +90 -0
- data/lib/redis/cluster/slot.rb +86 -0
- data/lib/redis/cluster/slot_loader.rb +49 -0
- data/lib/redis/connection.rb +4 -2
- data/lib/redis/connection/command_helper.rb +5 -10
- data/lib/redis/connection/hiredis.rb +12 -8
- data/lib/redis/connection/registry.rb +2 -1
- data/lib/redis/connection/ruby.rb +232 -63
- data/lib/redis/connection/synchrony.rb +41 -14
- data/lib/redis/distributed.rb +205 -70
- data/lib/redis/errors.rb +48 -0
- data/lib/redis/hash_ring.rb +31 -73
- data/lib/redis/pipeline.rb +74 -18
- data/lib/redis/subscribe.rb +24 -13
- data/lib/redis/version.rb +3 -1
- metadata +63 -160
- data/.gitignore +0 -10
- data/.order +0 -169
- data/.travis.yml +0 -50
- data/.travis/Gemfile +0 -11
- data/.yardopts +0 -3
- data/Rakefile +0 -392
- data/benchmarking/logging.rb +0 -62
- 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/examples/basic.rb +0 -15
- 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 -31
- data/examples/sets.rb +0 -36
- data/examples/unicorn/config.ru +0 -3
- data/examples/unicorn/unicorn.rb +0 -20
- data/redis.gemspec +0 -41
- data/test/blocking_commands_test.rb +0 -42
- data/test/command_map_test.rb +0 -30
- data/test/commands_on_hashes_test.rb +0 -21
- data/test/commands_on_lists_test.rb +0 -20
- data/test/commands_on_sets_test.rb +0 -77
- data/test/commands_on_sorted_sets_test.rb +0 -109
- data/test/commands_on_strings_test.rb +0 -83
- data/test/commands_on_value_types_test.rb +0 -99
- data/test/connection_handling_test.rb +0 -189
- data/test/db/.gitignore +0 -1
- data/test/distributed_blocking_commands_test.rb +0 -46
- data/test/distributed_commands_on_hashes_test.rb +0 -10
- data/test/distributed_commands_on_lists_test.rb +0 -22
- data/test/distributed_commands_on_sets_test.rb +0 -83
- data/test/distributed_commands_on_sorted_sets_test.rb +0 -18
- data/test/distributed_commands_on_strings_test.rb +0 -48
- data/test/distributed_commands_on_value_types_test.rb +0 -87
- data/test/distributed_commands_requiring_clustering_test.rb +0 -148
- data/test/distributed_connection_handling_test.rb +0 -23
- data/test/distributed_internals_test.rb +0 -15
- data/test/distributed_key_tags_test.rb +0 -52
- data/test/distributed_persistence_control_commands_test.rb +0 -26
- data/test/distributed_publish_subscribe_test.rb +0 -92
- data/test/distributed_remote_server_control_commands_test.rb +0 -53
- data/test/distributed_scripting_test.rb +0 -102
- data/test/distributed_sorting_test.rb +0 -20
- data/test/distributed_test.rb +0 -58
- data/test/distributed_transactions_test.rb +0 -32
- data/test/encoding_test.rb +0 -18
- data/test/error_replies_test.rb +0 -59
- data/test/helper.rb +0 -188
- data/test/helper_test.rb +0 -22
- data/test/internals_test.rb +0 -214
- data/test/lint/blocking_commands.rb +0 -124
- data/test/lint/hashes.rb +0 -162
- data/test/lint/lists.rb +0 -143
- data/test/lint/sets.rb +0 -96
- data/test/lint/sorted_sets.rb +0 -201
- data/test/lint/strings.rb +0 -157
- data/test/lint/value_types.rb +0 -106
- data/test/persistence_control_commands_test.rb +0 -26
- data/test/pipelining_commands_test.rb +0 -195
- data/test/publish_subscribe_test.rb +0 -153
- data/test/remote_server_control_commands_test.rb +0 -104
- data/test/scripting_test.rb +0 -78
- data/test/sorting_test.rb +0 -45
- 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 -92
- data/test/support/wire/synchrony.rb +0 -24
- data/test/support/wire/thread.rb +0 -5
- data/test/synchrony_driver.rb +0 -57
- data/test/test.conf +0 -9
- data/test/thread_safety_test.rb +0 -32
- data/test/transactions_test.rb +0 -244
- data/test/unknown_commands_test.rb +0 -14
- data/test/url_param_test.rb +0 -64
data/test/lint/sorted_sets.rb
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
module Lint
|
2
|
-
|
3
|
-
module SortedSets
|
4
|
-
|
5
|
-
def test_zadd
|
6
|
-
assert_equal 0, r.zcard("foo")
|
7
|
-
assert_equal true, r.zadd("foo", 1, "s1")
|
8
|
-
assert_equal false, r.zadd("foo", 1, "s1")
|
9
|
-
assert_equal 1, r.zcard("foo")
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_variadic_zadd
|
13
|
-
return if version < "2.3.9" # 2.4-rc6
|
14
|
-
|
15
|
-
# Non-nested array with pairs
|
16
|
-
assert_equal 0, r.zcard("foo")
|
17
|
-
assert_equal 2, r.zadd("foo", [1, "s1", 2, "s2"])
|
18
|
-
assert_equal 1, r.zadd("foo", [4, "s1", 5, "s2", 6, "s3"])
|
19
|
-
assert_equal 3, r.zcard("foo")
|
20
|
-
r.del "foo"
|
21
|
-
|
22
|
-
# Nested array with pairs
|
23
|
-
assert_equal 0, r.zcard("foo")
|
24
|
-
assert_equal 2, r.zadd("foo", [[1, "s1"], [2, "s2"]])
|
25
|
-
assert_equal 1, r.zadd("foo", [[4, "s1"], [5, "s2"], [6, "s3"]])
|
26
|
-
assert_equal 3, r.zcard("foo")
|
27
|
-
r.del "foo"
|
28
|
-
|
29
|
-
# Wrong number of arguments
|
30
|
-
assert_raise(Redis::CommandError) { r.zadd("foo", ["bar"]) }
|
31
|
-
assert_raise(Redis::CommandError) { r.zadd("foo", ["bar", "qux", "zap"]) }
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_zrem
|
35
|
-
r.zadd("foo", 1, "s1")
|
36
|
-
r.zadd("foo", 2, "s2")
|
37
|
-
|
38
|
-
assert_equal 2, r.zcard("foo")
|
39
|
-
assert_equal true, r.zrem("foo", "s1")
|
40
|
-
assert_equal false, r.zrem("foo", "s1")
|
41
|
-
assert_equal 1, r.zcard("foo")
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_variadic_zrem
|
45
|
-
return if version < "2.3.9" # 2.4-rc6
|
46
|
-
|
47
|
-
r.zadd("foo", 1, "s1")
|
48
|
-
r.zadd("foo", 2, "s2")
|
49
|
-
r.zadd("foo", 3, "s3")
|
50
|
-
|
51
|
-
assert_equal 3, r.zcard("foo")
|
52
|
-
assert_equal 1, r.zrem("foo", ["s1", "aaa"])
|
53
|
-
assert_equal 0, r.zrem("foo", ["bbb", "ccc" "ddd"])
|
54
|
-
assert_equal 1, r.zrem("foo", ["eee", "s3"])
|
55
|
-
assert_equal 1, r.zcard("foo")
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_zincrby
|
59
|
-
rv = r.zincrby "foo", 1, "s1"
|
60
|
-
assert_equal 1.0, rv
|
61
|
-
|
62
|
-
rv = r.zincrby "foo", 10, "s1"
|
63
|
-
assert_equal 11.0, rv
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_zrank
|
67
|
-
r.zadd "foo", 1, "s1"
|
68
|
-
r.zadd "foo", 2, "s2"
|
69
|
-
r.zadd "foo", 3, "s3"
|
70
|
-
|
71
|
-
assert_equal 2, r.zrank("foo", "s3")
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_zrevrank
|
75
|
-
r.zadd "foo", 1, "s1"
|
76
|
-
r.zadd "foo", 2, "s2"
|
77
|
-
r.zadd "foo", 3, "s3"
|
78
|
-
|
79
|
-
assert_equal 0, r.zrevrank("foo", "s3")
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_zrange
|
83
|
-
r.zadd "foo", 1, "s1"
|
84
|
-
r.zadd "foo", 2, "s2"
|
85
|
-
r.zadd "foo", 3, "s3"
|
86
|
-
|
87
|
-
assert_equal ["s1", "s2"], r.zrange("foo", 0, 1)
|
88
|
-
assert_equal [["s1", 1.0], ["s2", 2.0]], r.zrange("foo", 0, 1, :with_scores => true)
|
89
|
-
assert_equal [["s1", 1.0], ["s2", 2.0]], r.zrange("foo", 0, 1, :withscores => true)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_zrevrange
|
93
|
-
r.zadd "foo", 1, "s1"
|
94
|
-
r.zadd "foo", 2, "s2"
|
95
|
-
r.zadd "foo", 3, "s3"
|
96
|
-
|
97
|
-
assert_equal ["s3", "s2"], r.zrevrange("foo", 0, 1)
|
98
|
-
assert_equal [["s3", 3.0], ["s2", 2.0]], r.zrevrange("foo", 0, 1, :with_scores => true)
|
99
|
-
assert_equal [["s3", 3.0], ["s2", 2.0]], r.zrevrange("foo", 0, 1, :withscores => true)
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_zrangebyscore
|
103
|
-
r.zadd "foo", 1, "s1"
|
104
|
-
r.zadd "foo", 2, "s2"
|
105
|
-
r.zadd "foo", 3, "s3"
|
106
|
-
|
107
|
-
assert_equal ["s2", "s3"], r.zrangebyscore("foo", 2, 3)
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_zrevrangebyscore
|
111
|
-
r.zadd "foo", 1, "s1"
|
112
|
-
r.zadd "foo", 2, "s2"
|
113
|
-
r.zadd "foo", 3, "s3"
|
114
|
-
|
115
|
-
assert_equal ["s3", "s2"], r.zrevrangebyscore("foo", 3, 2)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_zrangebyscore_with_limit
|
119
|
-
r.zadd "foo", 1, "s1"
|
120
|
-
r.zadd "foo", 2, "s2"
|
121
|
-
r.zadd "foo", 3, "s3"
|
122
|
-
r.zadd "foo", 4, "s4"
|
123
|
-
|
124
|
-
assert_equal ["s2"], r.zrangebyscore("foo", 2, 4, :limit => [0, 1])
|
125
|
-
assert_equal ["s3"], r.zrangebyscore("foo", 2, 4, :limit => [1, 1])
|
126
|
-
assert_equal ["s3", "s4"], r.zrangebyscore("foo", 2, 4, :limit => [1, 2])
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_zrevrangebyscore_with_limit
|
130
|
-
r.zadd "foo", 1, "s1"
|
131
|
-
r.zadd "foo", 2, "s2"
|
132
|
-
r.zadd "foo", 3, "s3"
|
133
|
-
r.zadd "foo", 4, "s4"
|
134
|
-
|
135
|
-
assert_equal ["s4"], r.zrevrangebyscore("foo", 4, 2, :limit => [0, 1])
|
136
|
-
assert_equal ["s3"], r.zrevrangebyscore("foo", 4, 2, :limit => [1, 1])
|
137
|
-
assert_equal ["s3", "s2"], r.zrevrangebyscore("foo", 4, 2, :limit => [1, 2])
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_zrangebyscore_with_withscores
|
141
|
-
r.zadd "foo", 1, "s1"
|
142
|
-
r.zadd "foo", 2, "s2"
|
143
|
-
r.zadd "foo", 3, "s3"
|
144
|
-
r.zadd "foo", 4, "s4"
|
145
|
-
|
146
|
-
assert_equal [["s2", 2.0]], r.zrangebyscore("foo", 2, 4, :limit => [0, 1], :with_scores => true)
|
147
|
-
assert_equal [["s3", 3.0]], r.zrangebyscore("foo", 2, 4, :limit => [1, 1], :with_scores => true)
|
148
|
-
assert_equal [["s2", 2.0]], r.zrangebyscore("foo", 2, 4, :limit => [0, 1], :withscores => true)
|
149
|
-
assert_equal [["s3", 3.0]], r.zrangebyscore("foo", 2, 4, :limit => [1, 1], :withscores => true)
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_zrevrangebyscore_with_withscores
|
153
|
-
r.zadd "foo", 1, "s1"
|
154
|
-
r.zadd "foo", 2, "s2"
|
155
|
-
r.zadd "foo", 3, "s3"
|
156
|
-
r.zadd "foo", 4, "s4"
|
157
|
-
|
158
|
-
assert_equal [["s4", 4.0]], r.zrevrangebyscore("foo", 4, 2, :limit => [0, 1], :with_scores => true)
|
159
|
-
assert_equal [["s3", 3.0]], r.zrevrangebyscore("foo", 4, 2, :limit => [1, 1], :with_scores => true)
|
160
|
-
assert_equal [["s4", 4.0]], r.zrevrangebyscore("foo", 4, 2, :limit => [0, 1], :withscores => true)
|
161
|
-
assert_equal [["s3", 3.0]], r.zrevrangebyscore("foo", 4, 2, :limit => [1, 1], :withscores => true)
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_zcard
|
165
|
-
assert_equal 0, r.zcard("foo")
|
166
|
-
|
167
|
-
r.zadd "foo", 1, "s1"
|
168
|
-
|
169
|
-
assert_equal 1, r.zcard("foo")
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_zscore
|
173
|
-
r.zadd "foo", 1, "s1"
|
174
|
-
|
175
|
-
assert_equal 1.0, r.zscore("foo", "s1")
|
176
|
-
|
177
|
-
assert_equal nil, r.zscore("foo", "s2")
|
178
|
-
assert_equal nil, r.zscore("bar", "s1")
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_zremrangebyrank
|
182
|
-
r.zadd "foo", 10, "s1"
|
183
|
-
r.zadd "foo", 20, "s2"
|
184
|
-
r.zadd "foo", 30, "s3"
|
185
|
-
r.zadd "foo", 40, "s4"
|
186
|
-
|
187
|
-
assert_equal 3, r.zremrangebyrank("foo", 1, 3)
|
188
|
-
assert_equal ["s1"], r.zrange("foo", 0, -1)
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_zremrangebyscore
|
192
|
-
r.zadd "foo", 1, "s1"
|
193
|
-
r.zadd "foo", 2, "s2"
|
194
|
-
r.zadd "foo", 3, "s3"
|
195
|
-
r.zadd "foo", 4, "s4"
|
196
|
-
|
197
|
-
assert_equal 3, r.zremrangebyscore("foo", 2, 4)
|
198
|
-
assert_equal ["s1"], r.zrange("foo", 0, -1)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
data/test/lint/strings.rb
DELETED
@@ -1,157 +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_ascii_characters
|
30
|
-
if defined?(Encoding)
|
31
|
-
with_external_encoding("ASCII-8BIT") do
|
32
|
-
(0..255).each do |i|
|
33
|
-
str = "#{i.chr}---#{i.chr}"
|
34
|
-
r.set("foo", str)
|
35
|
-
|
36
|
-
assert_equal str, r.get("foo")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_setex
|
43
|
-
assert r.setex("foo", 1, "bar")
|
44
|
-
assert_equal "bar", r.get("foo")
|
45
|
-
assert [0, 1].include? r.ttl("foo")
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_psetex
|
49
|
-
return if version < "2.5.4"
|
50
|
-
|
51
|
-
assert r.psetex("foo", 1000, "bar")
|
52
|
-
assert_equal "bar", r.get("foo")
|
53
|
-
assert [0, 1].include? r.ttl("foo")
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_getset
|
57
|
-
r.set("foo", "bar")
|
58
|
-
|
59
|
-
assert_equal "bar", r.getset("foo", "baz")
|
60
|
-
assert_equal "baz", r.get("foo")
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_setnx
|
64
|
-
r.set("foo", "s1")
|
65
|
-
|
66
|
-
assert_equal "s1", r.get("foo")
|
67
|
-
|
68
|
-
r.setnx("foo", "s2")
|
69
|
-
|
70
|
-
assert_equal "s1", r.get("foo")
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_incr
|
74
|
-
assert_equal 1, r.incr("foo")
|
75
|
-
assert_equal 2, r.incr("foo")
|
76
|
-
assert_equal 3, r.incr("foo")
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_incrby
|
80
|
-
assert_equal 1, r.incrby("foo", 1)
|
81
|
-
assert_equal 3, r.incrby("foo", 2)
|
82
|
-
assert_equal 6, r.incrby("foo", 3)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_incrbyfloat
|
86
|
-
return if version < "2.5.4"
|
87
|
-
|
88
|
-
assert_equal 1.23, r.incrbyfloat("foo", 1.23)
|
89
|
-
assert_equal 2 , r.incrbyfloat("foo", 0.77)
|
90
|
-
assert_equal 1.9 , r.incrbyfloat("foo", -0.1)
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_decr
|
94
|
-
r.set("foo", 3)
|
95
|
-
|
96
|
-
assert_equal 2, r.decr("foo")
|
97
|
-
assert_equal 1, r.decr("foo")
|
98
|
-
assert_equal 0, r.decr("foo")
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_decrby
|
102
|
-
r.set("foo", 6)
|
103
|
-
|
104
|
-
assert_equal 3, r.decrby("foo", 3)
|
105
|
-
assert_equal 1, r.decrby("foo", 2)
|
106
|
-
assert_equal 0, r.decrby("foo", 1)
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_append
|
110
|
-
r.set "foo", "s"
|
111
|
-
r.append "foo", "1"
|
112
|
-
|
113
|
-
assert_equal "s1", r.get("foo")
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_getbit
|
117
|
-
r.set("foo", "a")
|
118
|
-
|
119
|
-
assert_equal 1, r.getbit("foo", 1)
|
120
|
-
assert_equal 1, r.getbit("foo", 2)
|
121
|
-
assert_equal 0, r.getbit("foo", 3)
|
122
|
-
assert_equal 0, r.getbit("foo", 4)
|
123
|
-
assert_equal 0, r.getbit("foo", 5)
|
124
|
-
assert_equal 0, r.getbit("foo", 6)
|
125
|
-
assert_equal 1, r.getbit("foo", 7)
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_setbit
|
129
|
-
r.set("foo", "a")
|
130
|
-
|
131
|
-
r.setbit("foo", 6, 1)
|
132
|
-
|
133
|
-
assert_equal "c", r.get("foo")
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_getrange
|
137
|
-
r.set("foo", "abcde")
|
138
|
-
|
139
|
-
assert_equal "bcd", r.getrange("foo", 1, 3)
|
140
|
-
assert_equal "abcde", r.getrange("foo", 0, -1)
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_setrange
|
144
|
-
r.set("foo", "abcde")
|
145
|
-
|
146
|
-
r.setrange("foo", 1, "bar")
|
147
|
-
|
148
|
-
assert_equal "abare", r.get("foo")
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_strlen
|
152
|
-
r.set "foo", "lorem"
|
153
|
-
|
154
|
-
assert_equal 5, r.strlen("foo")
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
data/test/lint/value_types.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
module Lint
|
2
|
-
|
3
|
-
module ValueTypes
|
4
|
-
|
5
|
-
def assert_in_range(range, value)
|
6
|
-
assert range.include?(value), "expected #{value} to be in #{range.inspect}"
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_exists
|
10
|
-
assert_equal false, r.exists("foo")
|
11
|
-
|
12
|
-
r.set("foo", "s1")
|
13
|
-
|
14
|
-
assert_equal true, r.exists("foo")
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_type
|
18
|
-
assert_equal "none", r.type("foo")
|
19
|
-
|
20
|
-
r.set("foo", "s1")
|
21
|
-
|
22
|
-
assert_equal "string", r.type("foo")
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_keys
|
26
|
-
r.set("f", "s1")
|
27
|
-
r.set("fo", "s2")
|
28
|
-
r.set("foo", "s3")
|
29
|
-
|
30
|
-
assert_equal ["f","fo", "foo"], r.keys("f*").sort
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_expire
|
34
|
-
r.set("foo", "s1")
|
35
|
-
assert r.expire("foo", 1)
|
36
|
-
assert_in_range 0..1, r.ttl("foo")
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_pexpire
|
40
|
-
return if version < "2.5.4"
|
41
|
-
|
42
|
-
r.set("foo", "s1")
|
43
|
-
assert r.pexpire("foo", 1000)
|
44
|
-
assert_in_range 0..1, r.ttl("foo")
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_expireat
|
48
|
-
r.set("foo", "s1")
|
49
|
-
assert r.expireat("foo", (Time.now + 1).to_i)
|
50
|
-
assert_in_range 0..1, r.ttl("foo")
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_pexpireat
|
54
|
-
return if version < "2.5.4"
|
55
|
-
|
56
|
-
r.set("foo", "s1")
|
57
|
-
assert r.pexpireat("foo", (Time.now + 1).to_i * 1_000)
|
58
|
-
assert_in_range 0..1, r.ttl("foo")
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_persist
|
62
|
-
r.set("foo", "s1")
|
63
|
-
r.expire("foo", 1)
|
64
|
-
r.persist("foo")
|
65
|
-
|
66
|
-
assert(-1 == r.ttl("foo"))
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_ttl
|
70
|
-
r.set("foo", "s1")
|
71
|
-
r.expire("foo", 1)
|
72
|
-
assert_in_range 0..1, r.ttl("foo")
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_pttl
|
76
|
-
return if version < "2.5.4"
|
77
|
-
|
78
|
-
r.set("foo", "s1")
|
79
|
-
r.expire("foo", 1)
|
80
|
-
assert_in_range 1..1000, r.pttl("foo")
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_move
|
84
|
-
r.select 14
|
85
|
-
r.flushdb
|
86
|
-
|
87
|
-
r.set "bar", "s3"
|
88
|
-
|
89
|
-
r.select 15
|
90
|
-
|
91
|
-
r.set "foo", "s1"
|
92
|
-
r.set "bar", "s2"
|
93
|
-
|
94
|
-
assert r.move("foo", 14)
|
95
|
-
assert_equal nil, r.get("foo")
|
96
|
-
|
97
|
-
assert !r.move("bar", 14)
|
98
|
-
assert_equal "s2", r.get("bar")
|
99
|
-
|
100
|
-
r.select 14
|
101
|
-
|
102
|
-
assert_equal "s1", r.get("foo")
|
103
|
-
assert_equal "s3", r.get("bar")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|