redis 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +9 -8
- data/.travis.yml +10 -8
- data/CHANGELOG.md +4 -0
- data/Rakefile +21 -10
- data/lib/redis.rb +229 -72
- data/lib/redis/version.rb +1 -1
- data/test/blocking_commands_test.rb +1 -1
- data/test/command_map_test.rb +1 -1
- data/test/commands_on_hashes_test.rb +1 -1
- data/test/commands_on_lists_test.rb +1 -1
- data/test/commands_on_sets_test.rb +1 -1
- data/test/commands_on_sorted_sets_test.rb +1 -1
- data/test/commands_on_strings_test.rb +14 -14
- data/test/commands_on_value_types_test.rb +1 -1
- data/test/connection_handling_test.rb +1 -1
- data/test/distributed_blocking_commands_test.rb +1 -1
- data/test/distributed_commands_on_hashes_test.rb +1 -1
- data/test/distributed_commands_on_lists_test.rb +1 -1
- data/test/distributed_commands_on_sets_test.rb +1 -1
- data/test/distributed_commands_on_sorted_sets_test.rb +1 -1
- data/test/distributed_commands_on_strings_test.rb +7 -7
- data/test/distributed_commands_on_value_types_test.rb +1 -1
- data/test/distributed_commands_requiring_clustering_test.rb +14 -14
- data/test/distributed_connection_handling_test.rb +1 -1
- data/test/distributed_internals_test.rb +1 -1
- data/test/distributed_key_tags_test.rb +1 -1
- data/test/distributed_persistence_control_commands_test.rb +1 -1
- data/test/distributed_publish_subscribe_test.rb +1 -1
- data/test/distributed_remote_server_control_commands_test.rb +15 -15
- data/test/distributed_scripting_test.rb +57 -57
- data/test/distributed_sorting_test.rb +1 -1
- data/test/distributed_test.rb +1 -1
- data/test/distributed_transactions_test.rb +1 -1
- data/test/encoding_test.rb +1 -1
- data/test/error_replies_test.rb +1 -1
- data/test/helper.rb +10 -1
- data/test/helper_test.rb +1 -1
- data/test/internals_test.rb +20 -9
- data/test/lint/hashes.rb +17 -17
- data/test/lint/lists.rb +10 -10
- data/test/lint/sets.rb +14 -14
- data/test/lint/sorted_sets.rb +30 -30
- data/test/lint/strings.rb +45 -45
- data/test/lint/value_types.rb +32 -32
- data/test/persistence_control_commands_test.rb +1 -1
- data/test/pipelining_commands_test.rb +1 -1
- data/test/publish_subscribe_test.rb +1 -1
- data/test/remote_server_control_commands_test.rb +7 -7
- data/test/scanning_test.rb +413 -0
- data/test/scripting_test.rb +45 -45
- data/test/sorting_test.rb +1 -1
- data/test/thread_safety_test.rb +1 -1
- data/test/transactions_test.rb +1 -1
- data/test/unknown_commands_test.rb +1 -1
- data/test/url_param_test.rb +1 -1
- metadata +6 -4
- data/test/db/.gitignore +0 -1
data/test/distributed_test.rb
CHANGED
data/test/encoding_test.rb
CHANGED
data/test/error_replies_test.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
$:.unshift File.expand_path(
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
$:.unshift File.expand_path(File.dirname(__FILE__))
|
2
3
|
|
3
4
|
require "test/unit"
|
4
5
|
require "logger"
|
@@ -153,6 +154,14 @@ module Helper
|
|
153
154
|
def assert_in_range(range, value)
|
154
155
|
assert range.include?(value), "expected #{value} to be in #{range.inspect}"
|
155
156
|
end
|
157
|
+
|
158
|
+
def target_version(target)
|
159
|
+
if version < target
|
160
|
+
skip("Requires Redis > #{target}") if respond_to?(:skip)
|
161
|
+
else
|
162
|
+
yield
|
163
|
+
end
|
164
|
+
end
|
156
165
|
end
|
157
166
|
|
158
167
|
module Client
|
data/test/helper_test.rb
CHANGED
data/test/internals_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "helper"
|
3
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class TestInternals < Test::Unit::TestCase
|
6
6
|
|
@@ -109,6 +109,17 @@ class TestInternals < Test::Unit::TestCase
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
def test_id_inside_multi
|
113
|
+
redis = Redis.new(OPTIONS)
|
114
|
+
id = nil
|
115
|
+
|
116
|
+
redis.multi do
|
117
|
+
id = redis.id
|
118
|
+
end
|
119
|
+
|
120
|
+
assert_equal id, "redis://127.0.0.1:6381/15"
|
121
|
+
end
|
122
|
+
|
112
123
|
driver(:ruby) do
|
113
124
|
def test_tcp_keepalive
|
114
125
|
keepalive = {:time => 20, :intvl => 10, :probes => 5}
|
@@ -128,16 +139,16 @@ class TestInternals < Test::Unit::TestCase
|
|
128
139
|
end
|
129
140
|
|
130
141
|
def test_time
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
rv = r.time
|
142
|
+
target_version "2.5.4" do
|
143
|
+
# Test that the difference between the time that Ruby reports and the time
|
144
|
+
# that Redis reports is minimal (prevents the test from being racy).
|
145
|
+
rv = r.time
|
136
146
|
|
137
|
-
|
138
|
-
|
147
|
+
redis_usec = rv[0] * 1_000_000 + rv[1]
|
148
|
+
ruby_usec = Integer(Time.now.to_f * 1_000_000)
|
139
149
|
|
140
|
-
|
150
|
+
assert 500_000 > (ruby_usec - redis_usec).abs
|
151
|
+
end
|
141
152
|
end
|
142
153
|
|
143
154
|
def test_connection_timeout
|
data/test/lint/hashes.rb
CHANGED
@@ -31,18 +31,18 @@ module Lint
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_variadic_hdel
|
34
|
-
|
34
|
+
target_version "2.3.9" do
|
35
|
+
r.hset("foo", "f1", "s1")
|
36
|
+
r.hset("foo", "f2", "s2")
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal "s1", r.hget("foo", "f1")
|
40
|
-
assert_equal "s2", r.hget("foo", "f2")
|
38
|
+
assert_equal "s1", r.hget("foo", "f1")
|
39
|
+
assert_equal "s2", r.hget("foo", "f2")
|
41
40
|
|
42
|
-
|
41
|
+
assert_equal 2, r.hdel("foo", ["f1", "f2"])
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
assert_equal nil, r.hget("foo", "f1")
|
44
|
+
assert_equal nil, r.hget("foo", "f2")
|
45
|
+
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_hexists
|
@@ -144,19 +144,19 @@ module Lint
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def test_hincrbyfloat
|
147
|
-
|
147
|
+
target_version "2.5.4" do
|
148
|
+
r.hincrbyfloat("foo", "f1", 1.23)
|
148
149
|
|
149
|
-
|
150
|
+
assert_equal "1.23", r.hget("foo", "f1")
|
150
151
|
|
151
|
-
|
152
|
+
r.hincrbyfloat("foo", "f1", 0.77)
|
152
153
|
|
153
|
-
|
154
|
+
assert_equal "2", r.hget("foo", "f1")
|
154
155
|
|
155
|
-
|
156
|
+
r.hincrbyfloat("foo", "f1", -0.1)
|
156
157
|
|
157
|
-
|
158
|
-
|
159
|
-
assert_equal "1.9", r.hget("foo", "f1")
|
158
|
+
assert_equal "1.9", r.hget("foo", "f1")
|
159
|
+
end
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
data/test/lint/lists.rb
CHANGED
@@ -11,11 +11,11 @@ module Lint
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_variadic_lpush
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
target_version "2.3.9" do # 2.4-rc6
|
15
|
+
assert_equal 3, r.lpush("foo", ["s1", "s2", "s3"])
|
16
|
+
assert_equal 3, r.llen("foo")
|
17
|
+
assert_equal "s3", r.lpop("foo")
|
18
|
+
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_lpushx
|
@@ -36,11 +36,11 @@ module Lint
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_variadic_rpush
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
target_version "2.3.9" do # 2.4-rc6
|
40
|
+
assert_equal 3, r.rpush("foo", ["s1", "s2", "s3"])
|
41
|
+
assert_equal 3, r.llen("foo")
|
42
|
+
assert_equal "s3", r.rpop("foo")
|
43
|
+
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_rpushx
|
data/test/lint/sets.rb
CHANGED
@@ -11,12 +11,12 @@ module Lint
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_variadic_sadd
|
14
|
-
|
14
|
+
target_version "2.3.9" do # 2.4-rc6
|
15
|
+
assert_equal 2, r.sadd("foo", ["s1", "s2"])
|
16
|
+
assert_equal 1, r.sadd("foo", ["s1", "s2", "s3"])
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
assert_equal ["s1", "s2", "s3"], r.smembers("foo").sort
|
18
|
+
assert_equal ["s1", "s2", "s3"], r.smembers("foo").sort
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_srem
|
@@ -30,17 +30,17 @@ module Lint
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_variadic_srem
|
33
|
-
|
33
|
+
target_version "2.3.9" do # 2.4-rc6
|
34
|
+
r.sadd("foo", "s1")
|
35
|
+
r.sadd("foo", "s2")
|
36
|
+
r.sadd("foo", "s3")
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
assert_equal 1, r.srem("foo", ["s1", "aaa"])
|
39
|
+
assert_equal 0, r.srem("foo", ["bbb", "ccc" "ddd"])
|
40
|
+
assert_equal 1, r.srem("foo", ["eee", "s3"])
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
assert_equal 1, r.srem("foo", ["eee", "s3"])
|
42
|
-
|
43
|
-
assert_equal ["s2"], r.smembers("foo")
|
42
|
+
assert_equal ["s2"], r.smembers("foo")
|
43
|
+
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_spop
|
data/test/lint/sorted_sets.rb
CHANGED
@@ -12,25 +12,25 @@ module Lint
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_variadic_zadd
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
15
|
+
target_version "2.3.9" do # 2.4-rc6
|
16
|
+
# Non-nested array with pairs
|
17
|
+
assert_equal 0, r.zcard("foo")
|
18
|
+
assert_equal 2, r.zadd("foo", [1, "s1", 2, "s2"])
|
19
|
+
assert_equal 1, r.zadd("foo", [4, "s1", 5, "s2", 6, "s3"])
|
20
|
+
assert_equal 3, r.zcard("foo")
|
21
|
+
r.del "foo"
|
22
|
+
|
23
|
+
# Nested array with pairs
|
24
|
+
assert_equal 0, r.zcard("foo")
|
25
|
+
assert_equal 2, r.zadd("foo", [[1, "s1"], [2, "s2"]])
|
26
|
+
assert_equal 1, r.zadd("foo", [[4, "s1"], [5, "s2"], [6, "s3"]])
|
27
|
+
assert_equal 3, r.zcard("foo")
|
28
|
+
r.del "foo"
|
29
|
+
|
30
|
+
# Wrong number of arguments
|
31
|
+
assert_raise(Redis::CommandError) { r.zadd("foo", ["bar"]) }
|
32
|
+
assert_raise(Redis::CommandError) { r.zadd("foo", ["bar", "qux", "zap"]) }
|
33
|
+
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_zrem
|
@@ -44,17 +44,17 @@ module Lint
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_variadic_zrem
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
47
|
+
target_version "2.3.9" do # 2.4-rc6
|
48
|
+
r.zadd("foo", 1, "s1")
|
49
|
+
r.zadd("foo", 2, "s2")
|
50
|
+
r.zadd("foo", 3, "s3")
|
51
|
+
|
52
|
+
assert_equal 3, r.zcard("foo")
|
53
|
+
assert_equal 1, r.zrem("foo", ["s1", "aaa"])
|
54
|
+
assert_equal 0, r.zrem("foo", ["bbb", "ccc" "ddd"])
|
55
|
+
assert_equal 1, r.zrem("foo", ["eee", "s3"])
|
56
|
+
assert_equal 1, r.zcard("foo")
|
57
|
+
end
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_zincrby
|
data/test/lint/strings.rb
CHANGED
@@ -48,40 +48,40 @@ module Lint
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_set_with_ex
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
55
|
end
|
56
56
|
|
57
57
|
def test_set_with_px
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
62
|
end
|
63
63
|
|
64
64
|
def test_set_with_nx
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
74
|
end
|
75
75
|
|
76
76
|
def test_set_with_xx
|
77
|
-
|
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")
|
78
81
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
r.del("foo")
|
84
|
-
assert !r.set("foo", "bar", :xx => true)
|
82
|
+
r.del("foo")
|
83
|
+
assert !r.set("foo", "bar", :xx => true)
|
84
|
+
end
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_setex
|
@@ -99,21 +99,21 @@ module Lint
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_psetex
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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
107
|
end
|
108
108
|
|
109
109
|
def test_psetex_with_non_string_value
|
110
|
-
|
110
|
+
target_version "2.5.4" do
|
111
|
+
value = ["b", "a", "r"]
|
111
112
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
assert [0, 1].include? r.ttl("foo")
|
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
117
|
end
|
118
118
|
|
119
119
|
def test_getset
|
@@ -167,11 +167,11 @@ module Lint
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def test_incrbyfloat
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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
175
|
end
|
176
176
|
|
177
177
|
def test_decr
|
@@ -218,12 +218,12 @@ module Lint
|
|
218
218
|
end
|
219
219
|
|
220
220
|
def test_bitcount
|
221
|
-
|
221
|
+
target_version "2.5.10" do
|
222
|
+
r.set("foo", "abcde")
|
222
223
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
assert_equal 17, r.bitcount("foo", 0, -1)
|
224
|
+
assert_equal 10, r.bitcount("foo", 1, 3)
|
225
|
+
assert_equal 17, r.bitcount("foo", 0, -1)
|
226
|
+
end
|
227
227
|
end
|
228
228
|
|
229
229
|
def test_getrange
|